public object Create(Type type) { if (!_entityTypes.Contains(type)) { return(_instanceCreator.Create(type)); } return(GetType() .GetMethod("CreateGeneric", BindingFlags.Instance | BindingFlags.NonPublic) .MakeGenericMethod(type) .Invoke(this, new object[] { })); }
private object CreateInstance(ConstructionNode node, BuildContext buildContext) { EnsureValidNode(node); var instanceType = node.InstantiateAs ?? node.InstanceType; var instance = creator.Create(instanceType, buildContext, node.InjectableArguments.Select(s => new InjectableMember(s))); NotifyNewInstance(buildContext, instance); if (node.Name != null) { buildContext.NamescopeAnnotator.RegisterName(node.Name, instance); } return(instance); }
public static T Create <T>(this IInstanceCreator creator) { return((T)creator.Create(typeof(T))); }