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);
        }
Beispiel #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));
 }
Beispiel #3
0
 public OtherThingBar(FileCode fileCode) : base(fileCode)
 {
 }
Beispiel #4
0
 public OtherThingFoo(FileCode fileCode) : base(fileCode)
 {
 }
Beispiel #5
0
 protected OtherThing(FileCode fileCode)
 {
     FileCode = fileCode;
 }
Beispiel #6
0
 public ThingBar(FileCode fileCode) : base(fileCode)
 {
 }
Beispiel #7
0
 public ThingFoo(FileCode fileCode) : base(fileCode)
 {
 }
Beispiel #8
0
 protected Thing(FileCode fileCode)
 {
     FileCode = fileCode;
 }
Beispiel #9
0
 public FileCodeParameter(FileCode fileCode)
 {
     this.fileCode = fileCode;
 }
Beispiel #10
0
 public FileProcessor Create(FileCode fileCode)
 {
     return(this.resolutionRoot.Get <FileProcessor>(new FileCodeParameter(fileCode)));
 }