Skip to content

Commit

Permalink
Merge pull request #858 from sean-gilliam/dry-di-extension
Browse files Browse the repository at this point in the history
Refactored common extension
  • Loading branch information
Aaronontheweb committed Apr 16, 2015
2 parents f488215 + abfda59 commit cd8008f
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 81 deletions.
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();
}
}
}

0 comments on commit cd8008f

Please sign in to comment.