Ejemplo n.º 1
0
        // Context
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public object NewInstance(ModuleInstance moduleInstance, object next, ProxyReferenceInvocationHandler proxyHandler)
        {
            var    injectionContext = new InjectionContext(moduleInstance, this.WrapNext(next), proxyHandler);
            object mixin            = this.injectedObjectBuilder.NewInstance(injectionContext);

            return(mixin);
        }
Ejemplo n.º 2
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public MethodConcernsInstance NewInstance(ModuleInstance moduleInstance, FragmentInvocationHandler mixinInvocationHandler)
        {
            var    proxyHandler = new ProxyReferenceInvocationHandler();
            object nextConcern  = mixinInvocationHandler;

            for (int i = this.concernsForMethod.Count - 1; i >= 0; i--)
            {
                MethodConcernModel concernModel = this.concernsForMethod[i];

                nextConcern = concernModel.NewInstance(moduleInstance, nextConcern, proxyHandler);
            }

            InvocationHandler firstConcern;

            if (nextConcern is InvocationHandler)
            {
                firstConcern = (InvocationHandler)nextConcern;
            }
            else
            {
                firstConcern = new TypedFragmentInvocationHandler(nextConcern);
            }

            return(new MethodConcernsInstance(firstConcern, mixinInvocationHandler, proxyHandler));
        }
Ejemplo n.º 3
0
        public ServiceReferenceInstance(ServiceModel serviceModel, ModuleInstance moduleInstance)
        {
            this.ServiceModel = serviceModel;
            this.moduleInstance = moduleInstance;

            this.serviceProxy = this.NewProxy();
        }
Ejemplo n.º 4
0
        public ServiceReferenceInstance(ServiceModel serviceModel, ModuleInstance moduleInstance)
        {
            this.ServiceModel   = serviceModel;
            this.moduleInstance = moduleInstance;

            this.serviceProxy = this.NewProxy();
        }
Ejemplo n.º 5
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            T foundModel = this.FindModel(moduleModel, visibility);

            if (foundModel != null)
            {
                if (this.Model == null)
                {
                    this.Model      = foundModel;
                    this.Module     = moduleInstance;
                    this.Visibility = visibility;
                }
                else
                {
                    // If same visibility -> ambiguous types
                    if (this.Visibility == visibility)
                    {
                        throw new Exception("AmbigiousType"); //AmbiguousTypeException(type);
                    }
                }
            }

            // Break if we have found a model and visibility has changed since the find
            return(!(this.Model != null && this.Visibility != visibility));
        }
Ejemplo n.º 6
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 protected AbstractCompositeInstance(AbstractCompositeModel compositeModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
 {
     this.CompositeModel = compositeModel;
     this.ModuleInstance = moduleInstance;
     this.Mixins         = mixins;
     this.State          = state;
     this.Proxy          = compositeModel.NewProxy(this);
 }
Ejemplo n.º 7
0
        public Module FindModule(string moduleName)
        {
            ModuleInstance moduleInstance = this.moduleInstances
                                            .Where(l => l.Model.Name == moduleName)
                                            .FirstOrDefault();

            return(moduleInstance);
        }
Ejemplo n.º 8
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 protected AbstractCompositeInstance(AbstractCompositeModel compositeModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
 {
     this.CompositeModel = compositeModel;
     this.ModuleInstance = moduleInstance;
     this.Mixins = mixins;
     this.State = state;
     this.Proxy = compositeModel.NewProxy(this);
 }
Ejemplo n.º 9
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public object Invoke(MethodInfo genericMethod, object proxy, object[] args, MixinsInstance mixins, ModuleInstance moduleInstance)
        {
            this.methodConstraintsInstance.CheckValid(proxy, args);

            CompositeMethodInstance methodInstance = this.GetInstance(genericMethod, moduleInstance);

            return mixins.Invoke(proxy, args, methodInstance);
        }
Ejemplo n.º 10
0
        public CompositeInstance NewValueInstance(ModuleInstance moduleInstance, UsesInstance uses, StateHolder stateHolder)
        {
            object[]          mixins            = this.mixinsModel.NewMixinHolder();
            CompositeInstance compositeInstance = new ValueInstance(this, moduleInstance, mixins, stateHolder);

            ((MixinsModel)this.mixinsModel).NewMixins(compositeInstance, uses, stateHolder, mixins);

            return(compositeInstance);
        }
Ejemplo n.º 11
0
        public CompositeInstance NewValueInstance(ModuleInstance moduleInstance, UsesInstance uses, StateHolder stateHolder)
        {
            object[] mixins = this.mixinsModel.NewMixinHolder();
            CompositeInstance compositeInstance = new ValueInstance(this, moduleInstance, mixins, stateHolder);

            ((MixinsModel)this.mixinsModel).NewMixins(compositeInstance, uses, stateHolder, mixins);

            return compositeInstance;
        }
Ejemplo n.º 12
0
        public ImportedServicesInstance NewInstance(ModuleInstance module)
        {
            this.serviceReferences = new List<ImportedServiceReferenceInstance>();
            foreach (ImportedServiceModel serviceModel in this.importedServiceModels)
            {
                var serviceReferenceInstance = new ImportedServiceReferenceInstance(serviceModel, module);
                this.serviceReferences.Add(serviceReferenceInstance);
            }

            return new ImportedServicesInstance(this, this.serviceReferences);
        }
Ejemplo n.º 13
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public object Invoke(MixinsInstance mixins, object proxy, MethodInfo method, object[] args, ModuleInstance moduleInstance)
        {
            CompositeMethodModel compositeMethod;

            if (this.methods.TryGetValue(method.ToDefinition(), out compositeMethod))
            {
                return compositeMethod.Invoke(method, proxy, args, mixins, moduleInstance);
            }

            return mixins.InvokeObject(proxy, args, method);
        }
Ejemplo n.º 14
0
        public ServicesInstance NewInstance(ModuleInstance moduleInstance)
        {
            var serviceReferences = new List<ServiceReference>();
            foreach (ServiceModel serviceModel in this.serviceModels)
            {
                var serviceReferenceInstance = new ServiceReferenceInstance(serviceModel, moduleInstance);
                serviceReferences.Add(serviceReferenceInstance);
            }

            return new ServicesInstance(this, serviceReferences);
        }
Ejemplo n.º 15
0
        public ImportedServicesInstance NewInstance(ModuleInstance module)
        {
            this.serviceReferences = new List <ImportedServiceReferenceInstance>();
            foreach (ImportedServiceModel serviceModel in this.importedServiceModels)
            {
                var serviceReferenceInstance = new ImportedServiceReferenceInstance(serviceModel, module);
                this.serviceReferences.Add(serviceReferenceInstance);
            }

            return(new ImportedServicesInstance(this, this.serviceReferences));
        }
Ejemplo n.º 16
0
        public ServicesInstance NewInstance(ModuleInstance moduleInstance)
        {
            var serviceReferences = new List <ServiceReference>();

            foreach (ServiceModel serviceModel in this.serviceModels)
            {
                var serviceReferenceInstance = new ServiceReferenceInstance(serviceModel, moduleInstance);
                serviceReferences.Add(serviceReferenceInstance);
            }

            return(new ServicesInstance(this, serviceReferences));
        }
Ejemplo n.º 17
0
        public LayerInstance NewInstance(ApplicationInstance applicationInstance, UsedLayersInstance usedLayerInstance)
        {
            var moduleInstances = new List <ModuleInstance>();
            var layerInstance   = new LayerInstance(this, applicationInstance, moduleInstances, usedLayerInstance);

            foreach (ModuleModel module in this.modules)
            {
                ModuleInstance moduleInstance = module.NewInstance(layerInstance);
                moduleInstances.Add(moduleInstance);
            }

            return(layerInstance);
        }
Ejemplo n.º 18
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public ServiceInstance NewInstance(ModuleInstance module)
        {
            object[] mixins          = this.mixinsModel.NewMixinHolder();
            var      serviceInstance = new ServiceInstance(this, module, mixins);

            var uses = new UsesInstance();

            uses.Use(this);

            // Instantiate all mixins
            ((MixinsModel)this.mixinsModel).NewMixins(serviceInstance,
                                                      uses,
                                                      null,
                                                      mixins);

            return(serviceInstance);
        }
Ejemplo n.º 19
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        private CompositeMethodInstance NewCompositeMethodInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
        {
            FragmentInvocationHandler mixinInvocationHandler = this.mixins.NewInvocationHandler(genericMethod);
            InvocationHandler invoker = mixinInvocationHandler;

            if (this.methodConcerns.HasConcerns)
            {
                MethodConcernsInstance concernsInstance = this.methodConcerns.NewInstance(moduleInstance, mixinInvocationHandler);
                invoker = concernsInstance;
            }
            if (this.methodSideEffects.HasSideEffects)
            {
                MethodSideEffectsInstance sideEffectsInstance = this.methodSideEffects.NewInstance(moduleInstance, invoker);
                invoker = sideEffectsInstance;
            }

            return new CompositeMethodInstance(invoker, mixinInvocationHandler, genericMethod, this.mixins.MethodIndex[genericMethod.ToDefinition()]);
        }
Ejemplo n.º 20
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 public MethodSideEffectsInstance NewInstance(ModuleInstance moduleInstance, InvocationHandler invoker)
 {
     var proxyHandler = new ProxyReferenceInvocationHandler();
     var result = new SideEffectInvocationHandlerResult();
     var sideEffects = new List<InvocationHandler>(this.sideEffectModels.Count);
     foreach (MethodSideEffectModel sideEffectModel in this.sideEffectModels)
     {
         object sideEffect = sideEffectModel.NewInstance(moduleInstance, result, proxyHandler);
         if (sideEffectModel.IsGeneric)
         {
             sideEffects.Add((InvocationHandler)sideEffect);
         }
         else
         {
             sideEffects.Add(new TypedFragmentInvocationHandler(sideEffect));
         }
     }
     return new MethodSideEffectsInstance(sideEffects, result, proxyHandler, invoker);
 }
Ejemplo n.º 21
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public MethodSideEffectsInstance NewInstance(ModuleInstance moduleInstance, InvocationHandler invoker)
        {
            var proxyHandler = new ProxyReferenceInvocationHandler();
            var result       = new SideEffectInvocationHandlerResult();
            var sideEffects  = new List <InvocationHandler>(this.sideEffectModels.Count);

            foreach (MethodSideEffectModel sideEffectModel in this.sideEffectModels)
            {
                object sideEffect = sideEffectModel.NewInstance(moduleInstance, result, proxyHandler);
                if (sideEffectModel.IsGeneric)
                {
                    sideEffects.Add((InvocationHandler)sideEffect);
                }
                else
                {
                    sideEffects.Add(new TypedFragmentInvocationHandler(sideEffect));
                }
            }
            return(new MethodSideEffectsInstance(sideEffects, result, proxyHandler, invoker));
        }
Ejemplo n.º 22
0
        public object ProvideInjection(InjectionContext context, InjectionAttribute attribute, Type fieldType)
        {
            object obj = context.Uses.UseForType(fieldType);

            if (obj != null)
            {
                return(obj);
            }

            ModuleInstance moduleInstance = context.ModuleInstance;

            TransientFinder compositeFinder = moduleInstance.FindCompositeModel(fieldType);

            if (compositeFinder.Model != null)
            {
                CompositeInstance compositeInstance = compositeFinder.Model.NewCompositeInstance(moduleInstance, context.Uses, context.State);
                context.Uses.Use(compositeInstance);
                return(compositeInstance.Proxy);
            }

            return(null);
        }
Ejemplo n.º 23
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public MethodConcernsInstance NewInstance(ModuleInstance moduleInstance, FragmentInvocationHandler mixinInvocationHandler)
        {
            var proxyHandler = new ProxyReferenceInvocationHandler();
            object nextConcern = mixinInvocationHandler;
            for (int i = this.concernsForMethod.Count - 1; i >= 0; i--)
            {
                MethodConcernModel concernModel = this.concernsForMethod[i];

                nextConcern = concernModel.NewInstance(moduleInstance, nextConcern, proxyHandler);
            }

            InvocationHandler firstConcern;
            if (nextConcern is InvocationHandler)
            {
                firstConcern = (InvocationHandler)nextConcern;
            }
            else
            {
                firstConcern = new TypedFragmentInvocationHandler(nextConcern);
            }

            return new MethodConcernsInstance(firstConcern, mixinInvocationHandler, proxyHandler);
        }
Ejemplo n.º 24
0
 public ServiceFinderInstance(ModuleInstance owner)
 {
     this.owner = owner;
 }
Ejemplo n.º 25
0
 public TransientBuilderInstance(ModuleInstance moduleInstance, TransientModel model)
 {
     this.moduleInstance = moduleInstance;
     this.transientModel = model;
 }
Ejemplo n.º 26
0
 public TransientBuilderInstance(ModuleInstance moduleInstance, TransientModel model, UsesInstance uses)
     : this(moduleInstance, model)
 {
     this.uses = uses;
 }
Ejemplo n.º 27
0
 public ValueInstance(ValueModel valueModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
     : base(valueModel, moduleInstance, mixins, state)
 {
 }
Ejemplo n.º 28
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        private CompositeMethodInstance NewCompositeMethodInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
        {
            FragmentInvocationHandler mixinInvocationHandler = this.mixins.NewInvocationHandler(genericMethod);
            InvocationHandler         invoker = mixinInvocationHandler;

            if (this.methodConcerns.HasConcerns)
            {
                MethodConcernsInstance concernsInstance = this.methodConcerns.NewInstance(moduleInstance, mixinInvocationHandler);
                invoker = concernsInstance;
            }
            if (this.methodSideEffects.HasSideEffects)
            {
                MethodSideEffectsInstance sideEffectsInstance = this.methodSideEffects.NewInstance(moduleInstance, invoker);
                invoker = sideEffectsInstance;
            }

            return(new CompositeMethodInstance(invoker, mixinInvocationHandler, genericMethod, this.mixins.MethodIndex[genericMethod.ToDefinition()]));
        }
Ejemplo n.º 29
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

            return this.Service == null;
        }
Ejemplo n.º 30
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            moduleInstance.GetServicesFor(this.Type, visibility, this.Services);

            return true;
        }
Ejemplo n.º 31
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public object Invoke(MethodInfo genericMethod, object proxy, object[] args, MixinsInstance mixins, ModuleInstance moduleInstance)
        {
            this.methodConstraintsInstance.CheckValid(proxy, args);

            CompositeMethodInstance methodInstance = this.GetInstance(genericMethod, moduleInstance);

            return(mixins.Invoke(proxy, args, methodInstance));
        }
Ejemplo n.º 32
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private CompositeMethodInstance GetInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
 {
     return(this.NewCompositeMethodInstance(genericMethod, moduleInstance));
 }
Ejemplo n.º 33
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            moduleInstance.GetServicesFor(this.Type, visibility, this.Services);

            return(true);
        }
Ejemplo n.º 34
0
 public ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model)
 {
     this.moduleInstance = moduleInstance;
     this.valueModel     = model;
 }
Ejemplo n.º 35
0
 public ValueBuilderFactoryInstance(ModuleInstance moduleInstance)
 {
     this.moduleInstance = moduleInstance;
 }
Ejemplo n.º 36
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public ServiceInstance NewInstance(ModuleInstance module)
        {
            object[] mixins = this.mixinsModel.NewMixinHolder();
            var serviceInstance = new ServiceInstance(this, module, mixins);

            var uses = new UsesInstance();
            uses.Use(this);

            // Instantiate all mixins
            ((MixinsModel)this.mixinsModel).NewMixins(serviceInstance,
                                                      uses,
                                                      null,
                                                      mixins);

            return serviceInstance;
        }
Ejemplo n.º 37
0
        //[DebuggerStepThrough]
        ////[DebuggerHidden]
        public object Invoke(MixinsInstance mixins, object proxy, MethodInfo method, object[] args, ModuleInstance moduleInstance)
        {
            CompositeMethodModel compositeMethod;

            if (this.methods.TryGetValue(method.ToDefinition(), out compositeMethod))
            {
                return(compositeMethod.Invoke(method, proxy, args, mixins, moduleInstance));
            }

            return(mixins.InvokeObject(proxy, args, method));
        }
Ejemplo n.º 38
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 public object Invoke(MixinsInstance mixins, CompositeInstance compositeInstance, object proxy, MethodInfo method, object[] args, ModuleInstance moduleInstance)
 {
     return(this.compositeMethodsModel.Invoke(mixins, proxy, method, args, moduleInstance));
 }
Ejemplo n.º 39
0
 public ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model, UsesInstance uses)
     : this(moduleInstance, model)
 {
     this.uses = uses;
 }
Ejemplo n.º 40
0
 public ValueInstance(ValueModel valueModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
         : base(valueModel, moduleInstance, mixins, state)
 {
 }
Ejemplo n.º 41
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 public object Invoke(MixinsInstance mixins, CompositeInstance compositeInstance, object proxy, MethodInfo method, object[] args, ModuleInstance moduleInstance)
 {
     return this.compositeMethodsModel.Invoke(mixins, proxy, method, args, moduleInstance);
 }
Ejemplo n.º 42
0
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

            return(this.Service == null);
        }
Ejemplo n.º 43
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private CompositeMethodInstance GetInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
 {
     return this.NewCompositeMethodInstance(genericMethod, moduleInstance);
 }
Ejemplo n.º 44
0
 // Context
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 public object NewInstance(ModuleInstance moduleInstance, object next, ProxyReferenceInvocationHandler proxyHandler)
 {
     var injectionContext = new InjectionContext(moduleInstance, this.WrapNext(next), proxyHandler);
     object mixin = this.injectedObjectBuilder.NewInstance(injectionContext);
     return mixin;
 }
Ejemplo n.º 45
0
 public ServiceFinderInstance(ModuleInstance owner)
 {
     this.owner = owner;
 }
 public TransientBuilderFactoryInstance(ModuleInstance moduleInstance)
 {
     this.moduleInstance = moduleInstance;
 }