// Create a ViralSharedInjectionContext to build the instance, no matter what kind of InjectionContext the current context is
        public TCurrent BuildAndShareInstance <TCurrent>(InjectionProcess <TCurrent> process, ObjectDescription description, ParameterSet parameters)
        {
            var myContext = new ViralSharedInjectionContext <TCurrent>(this, description, parameters);

            process.Execute(myContext);
            return(myContext.Instance);
        }
示例#2
0
        internal InjectionProcess <T> CreateInjectionProcess <T>(Kernel kernel)
        {
            if (_defaultGroup == null)
            {
                throw new InvalidOperationException("");
            }

            List <DependencyProvider> dependencyProviders;
            var activity = _defaultGroup.CreateInjectionActivity <T>(kernel, out dependencyProviders);

            var process = new InjectionProcess <T>();

            process.AddActivity(activity);

            if (_customGroups == null)
            {
                _admin.BuildDependencyRelationship(dependencyProviders);
                return(process);
            }

            for (int i = 0; i < _customGroups.Count; i++)
            {
                List <DependencyProvider> depProviders;
                var customActivity = _customGroups[i].CreateInjectionActivity <T>(kernel, out depProviders);
                if (depProviders != null)
                {
                    if (dependencyProviders == null)
                    {
                        dependencyProviders = depProviders;
                    }
                    else
                    {
                        dependencyProviders.AddRange(depProviders);
                    }
                }
                process.AddActivity(customActivity);
            }

            _admin.BuildDependencyRelationship(dependencyProviders);
            return(process);
        }
 public SharedInjectionOperator(ObjectBuilder <T> builder, ObjectDescription description, Lifetime <T> lifetime, InjectionProcess <T> process)
     : base(builder, description, lifetime)
 {
     _process = process;
 }
 // Create a NonViralSharedInjectionContext to build the instance, but if the current context is already a ViralSharedInjectionContext,
 // then it will create a ViralSharedInjectionContext also
 public abstract TCurrent BuildInstance <TCurrent>(InjectionProcess <TCurrent> process,
                                                   ObjectDescription description, ParameterSet parameters);
 public override TCurrent BuildInstance <TCurrent>(InjectionProcess <TCurrent> process, ObjectDescription description, ParameterSet parameters)
 {
     throw new NotImplementedException();
 }