Skip to content

onureker/Windsor.Extension

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windsor.Extension

Windsor.Extension is an extension library for open source container [Castle Windsor](http://www.castleproject.org/projects/windsor/). Library solves frequently needed features of this container.

Some of the features that provided in this libary is

  • Decoration pattern registration - Simple, chained, and type-safe (Both for Component and BasedOnDescriptor)
  • ResolveByParameterName in construction (without explicit registration)
  • AppSettings Convention
  • Static access for ExtenionMethod classes

Sample codes are included in repostory

Build Status

Features

Decoration Pattern Registration

This feature is the one the most needed feature in registration. However there are some tricks to cover this feature, it is too confusing and complex. Extension library solves this need by simple extension methods. Extension methods handles type-safety and decoration order

Component
    .For<IMathService>()
    .ImplementedBy<DefaultMathService>()
    .Decorated().By<LogDecorator>()
    .Decorated().By<ExceptionDecorator>()

Also it supports BasedOnDescriptor TODO

ResolveByParameterName

This feature provides to ability to resolve any class, if only constructor parameter is matched with registration name Detailed information can be found at here

Extension library solves this need just by adding ResolveByNameConvention resolver.

container.Kernel.Resolver.AddSubResolver(new ResolveByNameConvention(container));

And register with name

Component
    .For<ILogger>()
    .ImplementedBy<ConsoleLogger>()
    .NamedAsParameter()
    .IsDefault(),

Component
    .For<ILogger>()
    .ImplementedBy<TraceLogger>()
    .NamedAsParameter()

That's it. Now you can own them in constructor with constructor parameter name

public ResolveByNameDemo(ILogger logger, ILogger consoleLogger, ILogger traceLogger)
{
    this.logger = logger;
    this.consoleLogger = consoleLogger;
    this.traceLogger = traceLogger;
}

Releases

See the releases.

License

Windsor Extension is licensed under the Apache 2.0 license. Refer to LICENSE for more information

Icons made by Freepik from Flaticon is licensed by Creative Commons BY 3.0