public void Register(IKernelInternal kernel) { // 1. Interceptor Registration kernel.Register( Component.For <LoggingInterceptor>() .ImplementedBy <LoggingInterceptor>()); // Another Interceptor registration. //kernel.Register( // Component.For<AnotherInterceptor>() // .ImplementedBy<AnotherInterceptor>()); // 2. Interceptor attached with Example Class. kernel.Register( Component.For <IExample>() .ImplementedBy <Example>() .Interceptors(InterceptorReference.ForType <LoggingInterceptor>()).Anywhere); // Mutiple Interceptors for the same class can be registered with one line as below. //kernel.Register( // Component.For<IExample>() // .ImplementedBy<Example>() // .Interceptors(new InterceptorReference[] { // InterceptorReference.ForType<LoggingInterceptor>(), // InterceptorReference.ForType<AnotherInterceptor>() // }).Anywhere); }
/// <summary> /// Performs the registration in the <see cref="T:Castle.MicroKernel.IKernel"/>. /// </summary> /// <param name="kernel">The kernel.</param> public void Register(IKernelInternal kernel) { kernel.Register(Component.For <IWindowManager, WindowManager>() .LifeStyle.Singleton, Component.For <IEventAggregator, EventAggregator>() .LifeStyle.Singleton); }
public void Init(IKernelInternal kernel) { this.kernel = kernel; #if !SILVERLIGHT InitStandardExtensions(); #endif }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (LoadByName(kernel)) { try { return(kernel.Resolve(componentName, componentType, additionalArguments, scope)); } catch (ComponentNotFoundException e) { if (actualSelectorType == typeof(DefaultDelegateComponentSelector) && fallbackToResolveByTypeIfNameNotFound == false) { e.Data["breakingChangeId"] = "typedFactoryFallbackToResolveByTypeIfNameNotFound"; e.Data["breakingChange"] = "This exception may have been caused by a breaking change between Windsor 2.5 and 3.0 See breakingchanges.txt for more details."; } throw; } } // Ignore thread-static parent context call stack tracking. Factory-resolved components // are already tracked by the factory itself and should not be added as burdens just because // we happen to be resolving in the call stack of some random component’s constructor. // Specifically, act the same as we would if the timing was slightly different and we were not // resolving within the call stack of the random component’s constructor. return(kernel.Resolve(componentType, additionalArguments, scope, ignoreParentContext: true)); }
/*/// <summary> * /// Constructs a container using the specified * /// <see cref = "IConfigurationInterpreter" /> implementation. * /// </summary> * /// <param name = "interpreter">The instance of an <see cref = "IConfigurationInterpreter" /> implementation.</param> * public EssexContainer(IConfigurationInterpreter interpreter) * : this() * { * if (interpreter == null) * { * throw new ArgumentNullException("interpreter"); * } * interpreter.ProcessResource(interpreter.Source, kernel.ConfigurationStore, kernel); * * RunInstaller(); * } * * /// <summary> * /// Constructs a container using the specified * /// <see cref = "IConfigurationStore" /> implementation. * /// </summary> * /// <param name = "store">The instance of an <see cref = "IConfigurationStore" /> implementation.</param> * public EssexContainer(IConfigurationStore store) * : this() * { * kernel.ConfigurationStore = store; * * RunInstaller(); * } * * * * /// <summary> * /// Initializes a new instance of the <see cref = "EssexContainer" /> class. * /// </summary> * /// <param name = "interpreter">The interpreter.</param> * /// <param name = "environmentInfo">The environment info.</param> * public EssexContainer(IConfigurationInterpreter interpreter, IEnvironmentInfo environmentInfo) * : this() * { * if (interpreter == null) * { * throw new ArgumentNullException("interpreter"); * } * if (environmentInfo == null) * { * throw new ArgumentNullException("environmentInfo"); * } * * interpreter.EnvironmentName = environmentInfo.GetEnvironmentName(); * interpreter.ProcessResource(interpreter.Source, kernel.ConfigurationStore, kernel); * * RunInstaller(); * }*/ public IEssexContainer Install(params IEssexInstaller[] installers) { if (installers == null) { throw new ArgumentNullException("installers"); } if (installers.Length != 0) { DefaultComponentInstaller scope = new DefaultComponentInstaller(); IKernelInternal kernel = this.kernel as IKernelInternal; if (kernel == null) { this.Install(installers, scope); } else { IDisposable disposable = kernel.OptimizeDependencyResolution(); this.Install(installers, scope); if (disposable != null) { disposable.Dispose(); } } } return(this); }
/// <summary> /// Constructs an AbstractComponentActivator /// </summary> protected AbstractComponentActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) { this.model = model; this.kernel = kernel; this.onCreation = onCreation; this.onDestruction = onDestruction; }
/// <summary> /// Initializes a new instance of the <see cref = "CreateOnUIThreadActivator" /> class. /// </summary> /// <param name = "model"> The model. </param> /// <param name = "kernel"> The kernel. </param> /// <param name = "onCreation"> Delegate called on construction. </param> /// <param name = "onDestruction"> Delegate called on destruction. </param> public CreateOnUIThreadActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { customActivator = CreateCustomActivator(model, kernel); performCreation = PerformCreation; }
/// <summary> /// Constructor for SessionFactoryActivator /// </summary> /// <param name="model"></param> /// <param name="kernel"></param> /// <param name="onCreation"></param> /// <param name="onDestruction"></param> public SessionFactoryActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public AspNetCoreComponentActivator( ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public WcfClientActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { clients = kernel.Resolve <WcfClientExtension>(); proxyFactory = new WcfProxyFactory(clients.ProxyGenerator, clients); }
/// <summary> /// Initializes a new instance of the <see cref = "DefaultComponentActivator" /> class. /// </summary> /// <param name = "model"> </param> /// <param name = "kernel"> </param> /// <param name = "onCreation"> </param> /// <param name = "onDestruction"> </param> public DefaultComponentActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { #if (!SILVERLIGHT) useFastCreateInstance = !model.Implementation.IsContextful && new SecurityPermission(SecurityPermissionFlag.SerializationFormatter).IsGranted(); #endif }
private void CollectForwardedTypes(IKernelInternal kernel, IConfiguration component, string typeName, string id, IConversionManager converter, List <Type> services) { if (kernel == null) { return; } var forwardedTypes = component.Children["forwardedTypes"]; if (forwardedTypes == null) { return; } foreach (var forwardedType in forwardedTypes.Children .Where(c => c.Name.Trim().Equals("add", StringComparison.InvariantCultureIgnoreCase))) { var forwardedServiceTypeName = forwardedType.Attributes["service"]; try { services.Add(converter.PerformConversion <Type>(forwardedServiceTypeName)); } catch (Exception e) { throw new ComponentRegistrationException( string.Format("Component {0}-{1} defines invalid forwarded type.", id ?? string.Empty, typeName), e); } } }
public void Register(IKernelInternal kernel) { //kernel.Register( // Component.For<SecurityInterceptor>() // .ImplementedBy<SecurityInterceptor>()); kernel.Register(Component.For <SecurityAspect>()); kernel.Register(Component.For <LoggingAspect>()); // Registrer All BLO Objects foreach (Type EntityType in new GwinEntitiesManager().GetAll_Entities_Type()) { Type BLOEntity_Type = GwinBaseBLO <BaseEntity> .Detemine_Type_EntityBLO(EntityType, GwinApp.Instance.TypeBaseBLO); // kernel.Register( //Component.For(BLOEntity_Type).ImplementedBy(BLOEntity_Type) // .Interceptors( // InterceptorReference.ForType<SecurityInterceptor>()).Anywhere); kernel.Register( Component.For(BLOEntity_Type).ImplementedBy(BLOEntity_Type) .Interceptors( typeof(SecurityAspect), typeof(LoggingAspect))); } }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (ComponentName != null && kernel.LoadHandlerByKey(ComponentName, ComponentType, AdditionalArguments) != null) { return kernel.Resolve(ComponentName, ComponentType, AdditionalArguments, scope); } return kernel.Resolve(ComponentType, AdditionalArguments, scope); }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (LoadByName(kernel)) { return kernel.Resolve(componentName, componentType, additionalArguments, scope); } return kernel.Resolve(componentType, additionalArguments, scope); }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (ComponentName != null && kernel.LoadHandlerByKey(ComponentName, ComponentType, AdditionalArguments) != null) { return(kernel.Resolve(ComponentName, ComponentType, AdditionalArguments, scope)); } return(kernel.Resolve(ComponentType, AdditionalArguments, scope)); }
private bool LoadByName(IKernelInternal kernel) { if (componentName == null) { return false; } return fallbackToResolveByTypeIfNameNotFound == false || kernel.LoadHandlerByKey(componentName, componentType, additionalArguments) != null; }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (LoadByName(kernel)) { return(kernel.Resolve(componentName, componentType, additionalArguments, scope)); } return(kernel.Resolve(componentType, additionalArguments, scope)); }
public WindsorServiceResolver(IKernel kernel) { _kernel = kernel as IKernelInternal; if (_kernel == null) { throw new ArgumentException($"The kernel must implement {typeof(IKernelInternal)}"); } }
public WindsorServiceProvider(IWindsorContainer container) { kernel = container.Kernel as IKernelInternal; if (kernel == null) { throw new ArgumentException(string.Format("The kernel must implement {0}", typeof(IKernelInternal))); } }
public WindsorServiceResolver(IKernel kernel) { _kernel = kernel as IKernelInternal; if (_kernel == null) { throw new ArgumentException(string.Format("The kernel must implement {0}", typeof(IKernelInternal))); } }
private bool LoadByName(IKernelInternal kernel) { if (componentName == null) { return(false); } return(fallbackToResolveByTypeIfNameNotFound == false || kernel.LoadHandlerByName(componentName, componentType, additionalArguments) != null); }
public ResourceProviderActivator( ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public NHibernateConfigurationActivator( ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public void Register(IKernelInternal kernel) { kernel.Register(Component.For<LoggingInterceptor>().ImplementedBy<LoggingInterceptor>()); kernel.Register( Component.For<ITask>().ImplementedBy<Task>().Interceptors( InterceptorReference.ForType<LoggingInterceptor>()).Anywhere); //Anywhere tells the registration process that this interceptor could be attached anywhere. }
public MessageHandlerActivator( ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { m_Endpoints = model.ExtendedProperties["MessageHandlerFor"] as string[]; }
public void Register(IKernelInternal kernel) { kernel.Register(Component.For <LoggingInterceptor>().ImplementedBy <LoggingInterceptor>()); kernel.Register( Component.For <ITask>().ImplementedBy <Task>().Interceptors( InterceptorReference.ForType <LoggingInterceptor>()).Anywhere); //Anywhere tells the registration process that this interceptor could be attached anywhere. }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (kernel.HasComponent(ComponentName) == false) { return kernel.Resolve(ComponentType, AdditionalArguments, scope); } return kernel.Resolve(ComponentName, ComponentType, AdditionalArguments, scope); }
public void Register(IKernelInternal kernel) { kernel.Register( Component.For <MethodLoggerInterceptor>() .ImplementedBy <MethodLoggerInterceptor>()); kernel.Register( Component.For <IPdfDocumentBuilder>() .ImplementedBy <PdfDocumentBuilder>() .Interceptors(InterceptorReference.ForType <MethodLoggerInterceptor>()).Anywhere); }
/// <summary> /// Performs the registration in the <see cref="T:Castle.MicroKernel.IKernel"/>. /// </summary> /// <param name="kernel">The kernel.</param> public void Register(IKernelInternal kernel) { kernel.Register(Component.For <IDataService, DataService>() .LifeStyle.Singleton, Component.For <IWorkspaceReaderWriter, WorkspaceReaderWriter>() .LifeStyle.Transient, Component.For <IWorkspaceReader, XmlWorkspaceReader>() .LifeStyle.Transient, Component.For <IWorkspaceWriter, XmlWorkspaceWriter>() .LifeStyle.Transient); }
public void Register(IKernelInternal kernel) { kernel.Register( Component.For <LoggingInterceptor>() .ImplementedBy <LoggingInterceptor>()); kernel.Register( Component.For <IRocket>() .ImplementedBy <Rocket>() .Interceptors(InterceptorReference.ForType <LoggingInterceptor>()).Anywhere); }
public void Register(IKernelInternal kernel) { kernel.Register( Component.For <TestInterceptor>() .ImplementedBy <TestInterceptor>()); kernel.Register( Component.For <OrderLogic>() .ImplementedBy <OrderLogic>() .Interceptors(InterceptorReference.ForType <TestInterceptor>()).Anywhere); }
public void Register(IKernelInternal kernel) { kernel.Register( Component.For <IInterceptor>() .ImplementedBy <ServiceInterceptor>()); kernel.Register( Component.For <IDemoService>() .ImplementedBy <DemoService>() .Interceptors(InterceptorReference.ForType <ServiceInterceptor>()).Anywhere); }
public void Register(IKernelInternal kernel) { kernel.Register( Component.For <StudentInterceptor>() .ImplementedBy <StudentInterceptor>()); kernel.Register( Component.For <IStudent>() .ImplementedBy <Student>() .Interceptors(InterceptorReference.ForType <StudentInterceptor>()).Anywhere); }
/// <summary> /// Performs the registration in the <see cref="T:Castle.MicroKernel.IKernel"/>. /// </summary> /// <param name="kernel">The kernel.</param> public void Register(IKernelInternal kernel) { kernel.Register(Component.For <IViewModelFactory, ViewModelFactory>().LifeStyle.Transient, Component.For <ModelEditorLoader>().LifeStyle.Transient, Component.For <SharedDomainLoader>().LifeStyle.Transient, Component.For <ConstraintLoader>().LifeStyle.Transient, Component.For <VariableLoader>().LifeStyle.Transient, Component.For <IWorkspaceLoader, WorkspaceLoader>().LifeStyle.Transient, Component.For <IResourceManager, ResourceManager>().LifeStyle.Singleton, Component.For <IDocumentManager, DocumentManager>().LifeStyle.Singleton); }
public override void Init(IKernelInternal kernel) { base.Init(kernel); if (resolveExtensions != null) { foreach (var extension in resolveExtensions) { extension.Init(kernel, this); } } if (releaseExtensions != null) { foreach (var extension in releaseExtensions) { extension.Init(kernel, this); } } }
/// <summary> /// Resolves the component(s) from given kernel. /// </summary> /// <param name = "kernel"></param> /// <param name = "scope"></param> /// <returns>Resolved component(s).</returns> public virtual object Resolve(IKernelInternal kernel, IReleasePolicy scope) { if (LoadByName(kernel)) { try { return kernel.Resolve(componentName, componentType, additionalArguments, scope); } catch (ComponentNotFoundException e) { if (actualSelectorType == typeof(DefaultDelegateComponentSelector) && fallbackToResolveByTypeIfNameNotFound == false) { e.Data["breakingChangeId"] = "typedFactoryFallbackToResolveByTypeIfNameNotFound"; e.Data["breakingChange"] = "This exception may have been caused by a breaking change between Windsor 2.5 and 3.0 See breakingchanges.txt for more details."; } throw; } } return kernel.Resolve(componentType, additionalArguments, scope); }
void IRegistration.Register(IKernelInternal kernel) { foreach (IWcfClientModel channel in channels) { var registration = Component.For(channel.Contract); registration.DependsOn(Property.ForKey("channel").Eq(channel)); if (configurer != null) { configurer(registration); } if (String.IsNullOrEmpty(registration.Name)) { registration.Named(Guid.NewGuid().ToString()); } if (!kernel.HasComponent(registration.Name)) { kernel.Register(registration); } } }
public TypedFactoryInterceptor(IKernelInternal kernel, ITypedFactoryComponentSelector componentSelector) { ComponentSelector = componentSelector; this.kernel = kernel; scope = kernel.ReleasePolicy.CreateSubPolicy(); }
public void Init(IKernelInternal kernel) { partial.Init(kernel); }
public PartialConfigurationStore(IKernelInternal kernel) { inner = kernel.ConfigurationStore; partial = new DefaultConfigurationStore(); partial.Init(kernel); }
public override void Init(IKernelInternal kernel) { base.Init(kernel); InitStandardExtensions(); }
/// <summary> /// Initializes a new instance of the <see cref = "WebUserControlComponentActivator" /> class. /// </summary> /// <param name = "model"> The model. </param> /// <param name = "kernel"> The kernel. </param> /// <param name = "onCreation"> The on creation. </param> /// <param name = "onDestruction"> The on destruction. </param> public WebUserControlComponentActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
/// <summary> /// Initializes a new instance of the <see cref = "RemoteActivatorThroughConnector" /> class. /// </summary> /// <param name = "model"> The model. </param> /// <param name = "kernel"> The kernel. </param> /// <param name = "onCreation"> The oncreation event handler. </param> /// <param name = "onDestruction"> The ondestruction event handler. </param> public RemoteActivatorThroughConnector(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public DefaultHandlerFactory(IKernelInternal kernel) { this.kernel = kernel; }
public override void Init(IKernelInternal kernel) { base.Init(kernel); kernel.Register(Component.For<IScopeManager>().Instance(this)); }
/// <summary> /// Saves the kernel instance, subscribes to /// <see cref = "IKernelEvents.AddedAsChildKernel" /> /// event, /// creates the lifestyle manager instance and computes /// the handler state. /// </summary> /// <param name = "kernel"></param> public virtual void Init(IKernel kernel) { if (kernel == null) { throw new ArgumentNullException("kernel"); } this.kernel = kernel as IKernelInternal; if (this.kernel == null) { throw new HandlerException( string.Format("The kernel does not implement {0}. It must also provide contract for internal usage.", typeof(IKernelInternal).FullName)); } this.kernel.AddedAsChildKernel += OnAddedAsChildKernel; var activator = this.kernel.CreateComponentActivator(ComponentModel); lifestyleManager = CreateLifestyleManager(activator); EnsureDependenciesCanBeSatisfied(activator as IDependencyAwareActivator); if (state == HandlerState.Valid) { DisconnectEvents(); } }
private void CollectForwardedTypes(IKernelInternal kernel, IConfiguration component, string typeName, string id, IConversionManager converter, List<Type> services) { if (kernel == null) { return; } var forwardedTypes = component.Children["forwardedTypes"]; if (forwardedTypes == null) { return; } foreach (var forwardedType in forwardedTypes.Children .Where(c => c.Name.Trim().Equals("add", StringComparison.InvariantCultureIgnoreCase))) { var forwardedServiceTypeName = forwardedType.Attributes["service"]; try { services.Add(converter.PerformConversion<Type>(forwardedServiceTypeName)); } catch (Exception e) { throw new Exception( string.Format("Component {0}-{1} defines invalid forwarded type.", id ?? string.Empty, typeName), e); } } }
/// <summary> /// Saves the kernel instance, subscribes to /// <see cref = "IKernelEvents.AddedAsChildKernel" /> /// event, /// creates the lifestyle manager instance and computes /// the handler state. /// </summary> /// <param name = "kernel"></param> public virtual void Init(IKernelInternal kernel) { if (kernel == null) { throw new ArgumentNullException("kernel"); } this.kernel = kernel; this.kernel.AddedAsChildKernel += OnAddedAsChildKernel; InitDependencies(); if (AllRequiredDependenciesResolvable()) { SetNewState(HandlerState.Valid); DisconnectEvents(); missingDependencies = null; } }
public virtual void Init(IKernelInternal kernel) { this.kernel = kernel; }
public void Register(IKernelInternal kernel) { kernel.Register(Component.For<IAnotherExample>().ImplementedBy<AnotherExample>()); }
/// <summary> /// Initializes a new instance of the <see cref = "RemoteMarshallerActivator" /> class. /// </summary> /// <param name = "model"> The model. </param> /// <param name = "kernel"> The kernel. </param> /// <param name = "onCreation"> The oncreation event handler. </param> /// <param name = "onDestruction"> The ondestruction event handler. </param> public RemoteMarshallerActivator(ComponentModel model, IKernelInternal kernel, ComponentInstanceDelegate onCreation, ComponentInstanceDelegate onDestruction) : base(model, kernel, onCreation, onDestruction) { }
public virtual void Init(IKernelInternal kernel) { }
/// <summary> /// Initializes this instance with the specified dependency delegate. /// </summary> /// <param name = "kernel">kernel</param> /// <param name = "dependencyDelegate">The dependency delegate.</param> public void Initialize(IKernelInternal kernel, DependencyDelegate dependencyDelegate) { this.kernel = kernel; converter = kernel.GetConversionManager(); dependencyResolvingDelegate = dependencyDelegate; }
public void Register(IKernelInternal kernel) { kernel.Register(Component.For<ILogger>().ImplementedBy<ConsoleLogger>()); }
public void Init(IKernelInternal kernel) { this.kernel = kernel; InitStandardExtensions(); }