// 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); }
//[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 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)); }
//[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); }
public Module FindModule(string moduleName) { ModuleInstance moduleInstance = this.moduleInstances .Where(l => l.Model.Name == moduleName) .FirstOrDefault(); return(moduleInstance); }
//[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); }
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 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); }
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)); }
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 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); }
//[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; }
public ValueInstance(ValueModel valueModel, ModuleInstance moduleInstance, object[] mixins, StateHolder state) : base(valueModel, moduleInstance, mixins, state) { }
//[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; }
//[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)); }
//[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); }
public ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model) { this.moduleInstance = moduleInstance; this.valueModel = model; }
public ValueBuilderFactoryInstance(ModuleInstance moduleInstance) { this.moduleInstance = moduleInstance; }
//[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)); }
//[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 ValueBuilderInstance(ModuleInstance moduleInstance, ValueModel model, UsesInstance uses) : this(moduleInstance, model) { this.uses = uses; }
//[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 TransientBuilderFactoryInstance(ModuleInstance moduleInstance) { this.moduleInstance = moduleInstance; }