public void FactMethodName()
        {
            var fooFileCode = new FileCode("foo");
            var barFileCode = new FileCode("bar");
            var kernel      = new StandardKernel();

            kernel
            .Bind <IFileProcessorFactory>()
            .To <FileProcessorFactory>();
            kernel
            .Bind <IThing>()
            .To <ThingFoo>()
            .WhenFileCode(fooFileCode);
            kernel
            .Bind <IThing>()
            .To <ThingBar>()
            .WhenFileCode(barFileCode);
            kernel
            .Bind <IOtherThing>()
            .To <OtherThingFoo>()
            .WhenFileCode(fooFileCode);
            kernel
            .Bind <IOtherThing>()
            .To <OtherThingBar>()
            .WhenFileCode(barFileCode);
            var fileProcessor = kernel.Get <IFileProcessorFactory>().Create(barFileCode);

            fileProcessor.Thing.Should().BeOfType <ThingBar>();
            fileProcessor.Thing.FileCode.Should().Be(barFileCode);
            fileProcessor.OtherThingWrapper.OtherThing.Should().BeOfType <OtherThingBar>();
            fileProcessor.OtherThingWrapper.OtherThing.FileCode.Should().Be(barFileCode);
        }
Example #2
0
 public static IBindingInNamedWithOrOnSyntax <T> WhenFileCode <T>(
     this IBindingWhenSyntax <T> syntax,
     FileCode fileCode)
 {
     return(syntax.When(req => req
                        .Parameters
                        .OfType <FileCodeParameter>()
                        .Single()
                        .FileCode.Value == fileCode.Value));
 }
Example #3
0
 public OtherThingBar(FileCode fileCode) : base(fileCode)
 {
 }
Example #4
0
 public OtherThingFoo(FileCode fileCode) : base(fileCode)
 {
 }
Example #5
0
 protected OtherThing(FileCode fileCode)
 {
     FileCode = fileCode;
 }
Example #6
0
 public ThingBar(FileCode fileCode) : base(fileCode)
 {
 }
Example #7
0
 public ThingFoo(FileCode fileCode) : base(fileCode)
 {
 }
Example #8
0
 protected Thing(FileCode fileCode)
 {
     FileCode = fileCode;
 }
Example #9
0
 public FileCodeParameter(FileCode fileCode)
 {
     this.fileCode = fileCode;
 }
Example #10
0
 public FileProcessor Create(FileCode fileCode)
 {
     return(this.resolutionRoot.Get <FileProcessor>(new FileCodeParameter(fileCode)));
 }