igloocoder.com Wiki
Navigation
Main Page
Random Page
Create a new Page
All Pages
Categories
Administration
File Management
Login/Logout
Language Selection
Your Profile
Create Account
Quick Search
Advanced Search »
Back
History
CSinsor
====This has been been removed from the commons framework. If you want fluent creation of Castle Windsor, it is now supported in the trunk build.==== <br><br> CSinsor is a wrapper around the Windsor container provided by the [http://www.castleproject.org|Castle project]. Container functionality is exactly the same as Windsor. All that is provided is a new mechanism for initializing the container itself.{BR} {BR} In all cases it is loading only objects that:{BR} - aren't abstract{BR} - aren't interfaces{BR} - implement at least one interface{BR} ==Sample== ===Simple Use=== This will intialize a CSinsorContainer with all the objects from the IglooCoder.Commons.Tests.dll assembly.{BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commons.Tests.dll"){BR} :);))){BR}{BR} ===Multiple Assemblies=== (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commons.Tests.dll"){BR} :::.For("IglooCoder.Commons.CSinsor.dll"){BR} :::.For("SomeCompany.SomeProduct.Data.dll"){BR} :);))){BR}{BR} ===Exclusion Filters=== In this example we show how to exclude components when loading the container. Because of the CSinsorAssemblyInitializer's fluent interface it's possible to add as many filters as you need.{BR} The WithExclusionOf method accepts a Predicate<Type> as it's parameter. When loading the container, all types are run through the provided Predicates and those which return false are loaded. As you can see in this example, there are three different namespaces being excluded from loading.{BR}{BR} '''NOTE:''' Exclusions will be applied to all assemblies that are being loaded. {BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commons.Tests.dll"){BR} :::.Add().ExclusionUsing(t => t.Namespace == "IglooCoder.Commons.Tests.HelperClassesForReflection.SecondNamespace"){BR} :::.Add().ExclusionUsing(t => t.Namespace == "IglooCoder.Commons.Tests.HelperClassesForReflection.SomeNamespace"){BR} :::.Add().ExclusionUsing(t => t.Namespace == "IglooCoder.Commons.Data"){BR} :);))) {BR}{BR} In this example we are excluding any component that does not belong to the provided namespace.{BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commons.Tests.dll"){BR} :::.Add().ExclusionUsing(t => t.Namespace != "IglooCoder.Commons.Tests.HelperClassesForReflection.SecondNamespace"){BR} :);))) {BR}{BR} Additionally we could exclude a specific component. {BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commons.Tests.dll"){BR} :::.Add().ExclusionUsing(t => t.Name == "SqlConnection"){BR} :);))){BR}{BR} ===Constructor Parameters=== Windsor's Xml based configuration allows for the addition of constructor parameter values. Those values are then applied to the constructor when the object is instantiated. CSinsor provides the ability to create constructor parameter values using it's fluent interface.{BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyINitializer(){BR} :::.For("IglooCoder.Commones.Tests.dll"){BR} :::.Parameters(Parameter.For<IPart>()ImplementedBy<Part>().Key("partName").Value("Some Part Name Goes Here")){BR} :);))){BR}{BR} It's possible to add as many parameters as you need.{BR}{BR} (((IWindsorContainer container = new CSinsorContainer().InitializeWith({BR} ::new CSinsorAssemblyInitializer(){BR} :::.For("IglooCoder.Commones.Tests.dll"){BR} :::.Parameters({BR} :::::Parameter.For<IPart>()ImplementedBy<Part>().Key("partName").Value("Some Part Name Goes Here"), :::::Parameter.For<IPart>()ImplementedBy<Part>().Key("id").Value("1") :::){BR} :);))){BR}{BR}
ScrewTurn Wiki
version 2.0.27. Some of the icons created by
FamFamFam
.