Cleaning BuildContext
This commit is contained in:
Родитель
6381e0990b
Коммит
e52e117c39
|
@ -1,4 +1,5 @@
|
|||
using System.Linq;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Unity.Builder;
|
||||
using Unity.ObjectBuilder.BuildPlan.DynamicMethod;
|
||||
|
@ -22,10 +23,10 @@ namespace BuildPlanCreatorExample
|
|||
_policies = policies;
|
||||
}
|
||||
|
||||
public IBuildPlanPolicy CreatePlan(ref BuilderContext context, INamedType buildKey)
|
||||
public IBuildPlanPolicy CreatePlan(ref BuilderContext context, Type type, string name)
|
||||
{
|
||||
// Make generic factory method for the type
|
||||
var typeToBuild = buildKey.Type.GetTypeInfo().GenericTypeArguments.First();
|
||||
var typeToBuild = type.GetTypeInfo().GenericTypeArguments.First();
|
||||
var factoryMethod =
|
||||
_factoryMethod.MakeGenericMethod(typeToBuild)
|
||||
.CreateDelegate(typeof(ResolveDelegate<BuilderContext>));
|
||||
|
@ -33,7 +34,7 @@ namespace BuildPlanCreatorExample
|
|||
var creatorPlan = new DynamicMethodBuildPlan(factoryMethod);
|
||||
|
||||
// Register BuildPlan policy with the container to optimize performance
|
||||
_policies.Set(buildKey.Type, string.Empty, typeof(IBuildPlanPolicy), creatorPlan);
|
||||
_policies.Set(type, string.Empty, typeof(IBuildPlanPolicy), creatorPlan);
|
||||
|
||||
return creatorPlan;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче