/// <summary> /// Registers a new weakly typed binding. /// </summary> /// <param name="instanceType"></param> /// <param name="configurator"></param> /// <param name="constructorSelector"></param> /// <param name="callerFilePath"></param> /// <param name="callerLineNumber"></param> public void Register(Type instanceType, Action <WeaklyTypedServiceConfigurator>?configurator = null, IConstructorResolver?constructorSelector = null, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) { RegisterInternal(instanceType, instanceType, configurator, constructorSelector, callerFilePath, callerLineNumber); }
private void DecorateInternal(Type dependencyType, Type decoratorType, Action <WeaklyTypedDecoratorConfigurator>?configurator, IConstructorResolver?constructorSelector, string callerFilePath, int callerLineNumber) { var metadata = new BindingMetadata(callerFilePath, callerLineNumber, Registrations.CurrentModule); var context = new WeaklyTypedDecoratorConfigurator(dependencyType, decoratorType, metadata, Settings, constructorSelector); configurator?.Invoke(context); Expression binding = context.ToBinding(); Registrations.AddDecorator(dependencyType, binding); }
/// <summary> /// Registers a new strongly typed binding. /// </summary> /// <typeparam name="TDependency"></typeparam> /// <typeparam name="TInstance"></typeparam> /// <param name="configurator"></param> /// <param name="constructorSelector"></param> /// <param name="callerFilePath"></param> /// <param name="callerLineNumber"></param> public void Register <TDependency, TInstance>(Action <StronglyTypedServiceConfigurator <TDependency, TInstance> >?configurator = null, IConstructorResolver?constructorSelector = null, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) where TInstance : class, TDependency { RegisterInternal(configurator, constructorSelector, callerFilePath, callerLineNumber); }
private void DecorateInternal <TDependency, TDecorator>(Action <StronglyTypedDecoratorConfigurator <TDependency, TDecorator> >?configurator, IConstructorResolver?constructorSelector, string callerFilePath, int callerLineNumber) where TDependency : class where TDecorator : TDependency { var metadata = new BindingMetadata(callerFilePath, callerLineNumber, Registrations.CurrentModule); var context = new StronglyTypedDecoratorConfigurator <TDependency, TDecorator>(metadata, Settings, constructorSelector); configurator?.Invoke(context); Expression binding = context.ToBinding(); Registrations.AddDecorator(typeof(TDependency), binding); }
private void RegisterInternal(Type dependencyType, Type instanceType, Action <WeaklyTypedServiceConfigurator>?configurator, IConstructorResolver?constructorSelector, string callerFilePath, int callerLineNumber) { var metadata = new BindingMetadata(callerFilePath, callerLineNumber, Registrations.CurrentModule); var context = new WeaklyTypedServiceConfigurator(dependencyType, instanceType, metadata, Settings, constructorSelector); configurator?.Invoke(context); ServiceBinding serviceBinding = context.ToBinding(); Registrations.AddBinding(serviceBinding); }
private void RegisterInternal <TDependency, TInstance>(Action <StronglyTypedServiceConfigurator <TDependency, TInstance> >?configurator, IConstructorResolver?constructorSelector, string callerFilePath, int callerLineNumber) where TInstance : class, TDependency { var metadata = new BindingMetadata(callerFilePath, callerLineNumber, Registrations.CurrentModule); var context = new StronglyTypedServiceConfigurator <TDependency, TInstance>(metadata, Settings, constructorSelector); configurator?.Invoke(context); ServiceBinding serviceBinding = context.ToBinding(); Registrations.AddBinding(serviceBinding); }
/// <summary> /// Registers a batch of new weakly typed decorators for <paramref name="dependencyType"/>. /// </summary> /// <param name="dependencyType"></param> /// <param name="decoratorTypes"></param> /// <param name="configurator"></param> /// <param name="constructorSelector"></param> /// <param name="callerFilePath"></param> /// <param name="callerLineNumber"></param> /// <returns></returns> public void Decorate(Type dependencyType, Type[] decoratorTypes, Action <WeaklyTypedDecoratorConfigurator>?configurator = null, IConstructorResolver?constructorSelector = null, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) { foreach (Type decoratorType in decoratorTypes) { DecorateInternal(dependencyType, decoratorType, configurator, constructorSelector, callerFilePath, callerLineNumber); } }
/// <summary> /// Registers a new strongly typed decorator for <typeparamref name="TDependency"/>. /// </summary> /// <typeparam name="TDependency">The type to decorate</typeparam> /// <typeparam name="TDecorator">The type of the decorator</typeparam> /// <exception cref="InterfaceExpectedException">If <typeparamref name="TDependency"/> is not a interface</exception> /// <returns></returns> public void Decorate <TDependency, TDecorator>(Action <StronglyTypedDecoratorConfigurator <TDependency, TDecorator> >?configurator = null, IConstructorResolver?constructorSelector = null, [CallerFilePath] string callerFilePath = "", [CallerLineNumber] int callerLineNumber = -1) where TDependency : class where TDecorator : TDependency { DecorateInternal(configurator, constructorSelector, callerFilePath, callerLineNumber); }