Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored common extension #858

Merged
merged 1 commit into from
Apr 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,4 @@ public void Release(ActorBase actor)
}
}
}
internal static class Extensions
{
public static Type GetTypeValue(this string typeName)
{
var firstTry = Type.GetType(typeName);
Func<Type> searchForType = () =>
{
return
AppDomain.
CurrentDomain.
GetAssemblies().
SelectMany(x => x.GetTypes()).
Where(t => t.Name.Equals(typeName)).
FirstOrDefault();
};
return firstTry ?? searchForType();
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,5 @@ public void Release(ActorBase actor)
{
this.container.Release(actor);
}

}
internal static class Extensions
{
public static Type GetTypeValue(this string typeName)
{
var firstTry = Type.GetType(typeName);
Func<Type> searchForType = () =>
{
return
AppDomain.
CurrentDomain.
GetAssemblies().
SelectMany(x => x.GetTypes()).
Where(t => t.Name.Equals(typeName)).
FirstOrDefault();
};
return firstTry ?? searchForType();
}

}
}

12 changes: 12 additions & 0 deletions src/contrib/dependencyInjection/Akka.DI.Core/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//-----------------------------------------------------------------------

using System;
using System.Linq;
using Akka.Actor;

namespace Akka.DI.Core
Expand Down Expand Up @@ -34,6 +35,17 @@ public static DIActorContextAdapter DI(this IActorContext context)
return new DIActorContextAdapter(context);
}

public static Type GetTypeValue(this string typeName)
{
var firstTry = Type.GetType(typeName);
Func<Type> searchForType = () =>
AppDomain.CurrentDomain
.GetAssemblies()
.SelectMany(x => x.GetTypes())
.FirstOrDefault(t => t.Name.Equals(typeName));

return firstTry ?? searchForType();
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -83,24 +83,4 @@ public void Release(ActorBase actor)
container.Release(actor);
}
}
internal static class Extensions
{
public static Type GetTypeValue(this string typeName)
{
var firstTry = Type.GetType(typeName);
Func<Type> searchForType = () =>
{
return
AppDomain.
CurrentDomain.
GetAssemblies().
SelectMany(x => x.GetTypes()).
Where(t => t.Name.Equals(typeName)).
FirstOrDefault();
};
return firstTry ?? searchForType();
}

}
}

Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,4 @@ public void Release(ActorBase actor)
container.Teardown(actor);
}
}

internal static class Extensions
{
public static Type GetTypeValue(this string typeName)
{
var firstTry = Type.GetType(typeName);
Func<Type> searchForType = () =>
{
return
AppDomain.
CurrentDomain.
GetAssemblies().
SelectMany(x => x.GetTypes()).
Where(t => t.Name.Equals(typeName)).
FirstOrDefault();
};
return firstTry ?? searchForType();
}
}
}