示例#1
0
        public void BootstrappingYourLibrariesWithFluentApis()
        {
            // To make my library, I can instantiate everything independantly
            var firstD1 = new Dependency();
            var firstD2 = new Dependency2 {
                SomeConfigurationProperty = "aa", SomeOptionalConfigurationProperty = "bb"
            };
            var firstLibraryInstantiation = new MyLibraryEntryPoint(firstD1, firstD2);

            // Or, you can offer a discoverable entry point and build a fluent interface
            var configured =
                MyFluentlyConfiguredLib.SetUp().With(
                    x =>
            {
                x.SomeConfigurationProperty = "my setting";
            })
                .AndSomeOptionalThing(x => { })
                .AndSomeOptionalThing(x => { })
                .AndSomeRequiredFinalThing(x => { });

            var secondInstance = configured.Create();
        }
        public void BootstrappingYourLibrariesWithFluentApis()
        {
            // To make my library, I can instantiate everything independantly
            var firstD1 = new Dependency();
            var firstD2 = new Dependency2 { SomeConfigurationProperty = "aa", SomeOptionalConfigurationProperty = "bb" };
            var firstLibraryInstantiation = new MyLibraryEntryPoint(firstD1, firstD2);

            // Or, you can offer a discoverable entry point and build a fluent interface
            var configured =
                MyFluentlyConfiguredLib.SetUp().With(
                    x =>
                    {
                        x.SomeConfigurationProperty = "my setting";
                    })
                    .AndSomeOptionalThing(x => { })
                    .AndSomeOptionalThing(x => { })
                    .AndSomeRequiredFinalThing(x => { });

            var secondInstance = configured.Create();
        }