Beispiel #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);
        }
Beispiel #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));
        }
        public ServiceReferenceInstance(ServiceModel serviceModel, ModuleInstance moduleInstance)
        {
            this.ServiceModel = serviceModel;
            this.moduleInstance = moduleInstance;

            this.serviceProxy = this.NewProxy();
        }
        public ServiceReferenceInstance(ServiceModel serviceModel, ModuleInstance moduleInstance)
        {
            this.ServiceModel   = serviceModel;
            this.moduleInstance = moduleInstance;

            this.serviceProxy = this.NewProxy();
        }
Beispiel #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));
        }
Beispiel #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);
 }
Beispiel #7
0
        public Module FindModule(string moduleName)
        {
            ModuleInstance moduleInstance = this.moduleInstances
                                            .Where(l => l.Model.Name == moduleName)
                                            .FirstOrDefault();

            return(moduleInstance);
        }
 //[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);
 }
        //[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);
        }
Beispiel #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);
        }
Beispiel #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;
        }
        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);
        }
        //[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);
        }
Beispiel #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);
        }
        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));
        }
Beispiel #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));
        }
Beispiel #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);
        }
Beispiel #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);
        }
        //[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()]);
        }
 //[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);
 }
        //[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));
        }
        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);
        }
        //[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);
        }
 public ServiceFinderInstance(ModuleInstance owner)
 {
     this.owner = owner;
 }
 public TransientBuilderInstance(ModuleInstance moduleInstance, TransientModel model)
 {
     this.moduleInstance = moduleInstance;
     this.transientModel = model;
 }
 public TransientBuilderInstance(ModuleInstance moduleInstance, TransientModel model, UsesInstance uses)
     : this(moduleInstance, model)
 {
     this.uses = uses;
 }
Beispiel #27
0
 public ValueInstance(ValueModel valueModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
     : base(valueModel, moduleInstance, mixins, state)
 {
 }
Beispiel #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()]));
        }
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

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

            return true;
        }
Beispiel #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));
        }
Beispiel #32
0
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private CompositeMethodInstance GetInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
 {
     return(this.NewCompositeMethodInstance(genericMethod, moduleInstance));
 }
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            moduleInstance.GetServicesFor(this.Type, visibility, this.Services);

            return(true);
        }
Beispiel #34
0
 public ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model)
 {
     this.moduleInstance = moduleInstance;
     this.valueModel     = model;
 }
Beispiel #35
0
 public ValueBuilderFactoryInstance(ModuleInstance moduleInstance)
 {
     this.moduleInstance = moduleInstance;
 }
Beispiel #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;
        }
        //[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));
        }
Beispiel #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));
 }
Beispiel #39
0
 public ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model, UsesInstance uses)
     : this(moduleInstance, model)
 {
     this.uses = uses;
 }
Beispiel #40
0
 public ValueInstance(ValueModel valueModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state)
         : base(valueModel, moduleInstance, mixins, state)
 {
 }
 //[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);
 }
        public bool VisitModule(ModuleInstance moduleInstance, ModuleModel moduleModel, Visibility visibility)
        {
            this.Service = moduleInstance.GetServiceFor(this.Type, visibility);

            return(this.Service == null);
        }
 //[DebuggerStepThrough]
 ////[DebuggerHidden]
 private CompositeMethodInstance GetInstance(MethodInfo genericMethod, ModuleInstance moduleInstance)
 {
     return this.NewCompositeMethodInstance(genericMethod, moduleInstance);
 }
 // 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;
 }
 public ServiceFinderInstance(ModuleInstance owner)
 {
     this.owner = owner;
 }
 public TransientBuilderFactoryInstance(ModuleInstance moduleInstance)
 {
     this.moduleInstance = moduleInstance;
 }