private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, string requestedName) { if (defaultInstance == null && pluginType.IsConcrete()) { defaultInstance = new ConfiguredInstance(pluginType); } var basicInstance = defaultInstance as IConfiguredInstance; var instance = basicInstance == null ? defaultInstance : basicInstance.Override(args); if (instance == null) { throw new StructureMapConfigurationException("No default instance or named instance '{0}' for requested plugin type {1}", requestedName, pluginType.GetFullName()); } var session = new BuildSession(_pipelineGraph, requestedName, args) { RootType = instance.ReturnedType }; return(session.FindObject(pluginType, instance)); }
/// <summary> /// Creates a new instance of the requested type using the supplied Instance. Mostly used internally /// </summary> /// <param name="pluginType"></param> /// <param name="instance"></param> /// <returns></returns> public object GetInstance(Type pluginType, Instance instance) { try { var session = new BuildSession(_pipelineGraph, instance.Name); return(session.FindObject(pluginType, instance)); } catch (StructureMapException e) { e.Push("Container.GetInstance({0}, Instance: {1})", pluginType.GetFullName(), instance.Description); throw; } }
private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, string requestedName) { if (defaultInstance == null && pluginType.IsConcrete()) { defaultInstance = new ConfiguredInstance(pluginType); } var basicInstance = defaultInstance as IConfiguredInstance; var instance = basicInstance == null ? defaultInstance : basicInstance.Override(args); var session = new BuildSession(_pipelineGraph, requestedName, args); return(session.FindObject(pluginType, instance)); }
/// <summary> /// Creates a new instance of the requested type using the supplied Instance. Mostly used internally /// </summary> /// <param name="pluginType"></param> /// <param name="instance"></param> /// <returns></returns> public object GetInstance(Type pluginType, Instance instance) { var session = new BuildSession(_pipelineGraph, instance.Name); return(session.FindObject(pluginType, instance)); }