Beispiel #1
0
 /// <summary>
 /// Gets the default instance of type T using the explicitly configured arguments from the "args"
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="args"></param>
 /// <returns></returns>
 public IEnumerable <T> GetAllInstances <T>(ExplicitArguments args)
 {
     try
     {
         var session = new BuildSession(_pipelineGraph, BuildSession.DEFAULT, args);
         return(session.GetAllInstances <T>());
     }
     catch (StructureMapException e)
     {
         e.Push("Container.GetAllInstances<{0}>({1})", typeof(T).GetFullName(), args);
         throw;
     }
 }
Beispiel #2
0
 /// <summary>
 ///     Creates or resolves all registered instances of type T
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <returns></returns>
 public IEnumerable <T> GetAllInstances <T>()
 {
     try
     {
         var session = new BuildSession(_pipelineGraph);
         return(session.GetAllInstances <T>());
     }
     catch (StructureMapException e)
     {
         e.Push("Container.GetAllInstances<{0}>()", typeof(T).GetFullName());
         throw;
     }
 }
Beispiel #3
0
 /// <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;
     }
 }
Beispiel #4
0
        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));
        }
Beispiel #5
0
        private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args,
                                             string requestedName)
        {
            if (defaultInstance == null && pluginType.IsConcrete())
            {
                defaultInstance = new ConfiguredInstance(pluginType);
            }

            var basicInstance = defaultInstance as ConstructorInstance;

            Instance instance = basicInstance == null
                                    ? defaultInstance
                                    : basicInstance.Override(args);

            BuildSession session = withNewSession(requestedName);

            args.RegisterDefaults(session);

            return(session.CreateInstance(pluginType, instance));
        }
        public object BuildNewInOriginalContext(Type pluginType, Instance instance)
        {
            var session = new BuildSession(pipelineGraph.Root(), requestedName: instance.Name);

            return(session.BuildNewInSession(pluginType, instance));
        }
Beispiel #7
0
        /// <summary>
        /// Creates or resolves all registered instances of type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IList <T> GetAllInstances <T>()
        {
            BuildSession session = withNewSession(Plugin.DEFAULT);

            return(getListOfTypeWithSession <T>(session));
        }
Beispiel #8
0
        /// <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));
        }
Beispiel #9
0
        /// <summary>
        ///     Creates or resolves all registered instances of type T
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public IEnumerable <T> GetAllInstances <T>()
        {
            var session = new BuildSession(_pipelineGraph);

            return(session.GetAllInstances <T>());
        }
Beispiel #10
0
        public IEnumerable <T> GetAllInstances <T>(ExplicitArguments args)
        {
            var session = new BuildSession(_pipelineGraph, Plugin.DEFAULT, args);

            return(session.GetAllInstances <T>());
        }