当前位置: 首页>>代码示例>>C#>>正文


C# Container.WhatDoIHave方法代码示例

本文整理汇总了C#中Container.WhatDoIHave方法的典型用法代码示例。如果您正苦于以下问题:C# Container.WhatDoIHave方法的具体用法?C# Container.WhatDoIHave怎么用?C# Container.WhatDoIHave使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Container的用法示例。


在下文中一共展示了Container.WhatDoIHave方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Given_structuremap_when_printWhatDoIHave_then_shouldReturnWhatDoIHave

 public void Given_structuremap_when_printWhatDoIHave_then_shouldReturnWhatDoIHave()
 {
     var container = new Container(new Registering());
     var printerInstance = container.TryGetInstance<ITypeOfPrinter>();
     string blackAndWhitePrintText = printerInstance.Printing();
     Assert.Pass(container.WhatDoIHave());
 }
开发者ID:JohanWe,项目名称:Code-Sample,代码行数:7,代码来源:TestStructuremap.cs

示例2: SetUp

        public void SetUp()
        {
            registry = new FubuRegistry(x =>
            {
                x.Route<InputModel>("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/prop")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub2/{Name}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route<InputModel>("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container();

            var bootstrapper = new StructureMapBootstrapper(container, registry);
            routes = new RouteCollection();

            bootstrapper.Bootstrap(routes);

            container.Configure(x => x.For<IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
开发者ID:cmdrkeem,项目名称:fubumvc,代码行数:30,代码来源:FubuBootstrapperIntegrationTester.cs

示例3: WhatDoIHave

        public void WhatDoIHave()
        {
            var container = new Container(x =>
            {
                x.For<IService>().Use<Service>();
            });

            var whatDoIHave = container.WhatDoIHave();

            var expectedWhatDoIHave = @"

            ===================================================================================================
            PluginType           Namespace        Lifecycle     Description                           Name
            ---------------------------------------------------------------------------------------------------
            Func<TResult>        System           Transient     Open Generic Template for Func<>      (Default)
            ---------------------------------------------------------------------------------------------------
            Func<T, TResult>     System           Transient     Open Generic Template for Func<,>     (Default)
            ---------------------------------------------------------------------------------------------------
            IContainer           StructureMap     Singleton     Object:  StructureMap.Container       (Default)
            ---------------------------------------------------------------------------------------------------
            IService             Core             Transient     Core.Service                          (Default)
            ---------------------------------------------------------------------------------------------------
            Lazy<T>              System           Transient     Open Generic Template for Func<>      (Default)
            ===================================================================================================";

            Assert.Equal(expectedWhatDoIHave, whatDoIHave);
        }
开发者ID:kendaleiv,项目名称:di-servicelocation-structuremap,代码行数:27,代码来源:TroubleshootingTests.cs

示例4: display_one_service_for_an_interface

        public void display_one_service_for_an_interface()
        {
            // SAMPLE: what_do_i_have_container
            var container = new Container(x =>
            {
                x.For<IEngine>().Use<Hemi>().Named("The Hemi");

                x.For<IEngine>().Add<VEight>().Singleton().Named("V8");
                x.For<IEngine>().Add<FourFiftyFour>().AlwaysUnique();
                x.For<IEngine>().Add<StraightSix>().LifecycleIs<ThreadLocalStorageLifecycle>();

                x.For<IEngine>().Add(() => new Rotary()).Named("Rotary");
                x.For<IEngine>().Add(c => c.GetInstance<PluginElectric>());

                x.For<IEngine>().Add(new InlineFour());

                x.For<IEngine>().UseIfNone<VTwelve>();
                x.For<IEngine>().MissingNamedInstanceIs.ConstructedBy(c => new NamedEngine(c.RequestedName));
            });
            // ENDSAMPLE

            // SAMPLE: whatdoihave_everything
            Debug.WriteLine(container.WhatDoIHave());
            // ENDSAMPLE
        }
开发者ID:slahn,项目名称:structuremap,代码行数:25,代码来源:WhatDoIHave_Smoke_Tester.cs

示例5: SetUp

        public void SetUp()
        {
            AssetDeclarationVerificationActivator.Latched = true;

            registry = new FubuRegistry(x =>
            {

                x.Route("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/prop")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub4/some_pattern")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container();

            routes = FubuApplication.For(registry).StructureMap(container).Bootstrap().Where(r => !r.As<Route>().Url.StartsWith("_content")).ToList();

            container.Configure(x => x.For<IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
开发者ID:hartez,项目名称:fubumvc,代码行数:33,代码来源:FubuBootstrapperIntegrationTester.cs

示例6: register_open_generic_type

        public void register_open_generic_type()
        {
            var container = new Container(_ =>
            {
                _.For(typeof(IVisualizer<>)).Use(typeof(DefaultVisualizer<>));
            });

            Debug.WriteLine(container.WhatDoIHave(@namespace: "StructureMap.Testing.Acceptance.Visualization"));

            container.GetInstance<IVisualizer<IssueCreated>>()
                .ShouldBeOfType<DefaultVisualizer<IssueCreated>>();

            Debug.WriteLine(container.WhatDoIHave(@namespace: "StructureMap.Testing.Acceptance.Visualization"));

            container.GetInstance<IVisualizer<IssueResolved>>()
                .ShouldBeOfType<DefaultVisualizer<IssueResolved>>();
        }
开发者ID:khellang,项目名称:structuremap,代码行数:17,代码来源:generic_types.cs

示例7: empty_container

        public void empty_container()
        {
            // SAMPLE: whatdoihave-simple
            var container = new Container();
            var report = container.WhatDoIHave();

            Debug.WriteLine(report);
            // ENDSAMPLE
        }
开发者ID:slahn,项目名称:structuremap,代码行数:9,代码来源:WhatDoIHave_Smoke_Tester.cs

示例8: allow_nested_container_to_report_what_it_has

        public void allow_nested_container_to_report_what_it_has()
        {
            var container = new Container(x => x.For<IAutomobile>().Use<Mustang>());

            var nestedContainer = container.GetNestedContainer();
            nestedContainer.Inject<IEngine>(new PushrodEngine());

            container.WhatDoIHave().ShouldNotBeEmpty().ShouldNotContain(typeof(IEngine).Name);
            nestedContainer.WhatDoIHave().ShouldNotBeEmpty().ShouldContain(typeof(IEngine).Name);
        }
开发者ID:khellang,项目名称:structuremap,代码行数:10,代码来源:NestedContainerSupportTester.cs

示例9: InitialiseContainer

        private static Container InitialiseContainer()
        {
            var container = new Container(x =>
            {
                x.AddRegistry<DependencyRegistry>();
            });

            Debug.WriteLine(container.WhatDoIHave());

            return container;
        }
开发者ID:james-wu,项目名称:Continuum,代码行数:11,代码来源:IocRegistry.cs

示例10: render_the_missing_named_instance_if_it_exists

        public void render_the_missing_named_instance_if_it_exists()
        {
            var container =
                new Container(
                    x =>
                    {
                        x.For<IEngine>().MissingNamedInstanceIs.ConstructedBy(c => new NamedEngine(c.RequestedName));
                    });

            var description = container.WhatDoIHave();
            description.ShouldContain("*Missing Named Instance*");
            description.ShouldContain("Lambda: new NamedEngine(IContext.RequestedName)");
        }
开发者ID:slahn,项目名称:structuremap,代码行数:13,代码来源:WhatDoIHave_Smoke_Tester.cs

示例11: clear_all_in_action

        public void clear_all_in_action()
        {
            var container = new Container(_ =>
            {
                _.For<IWidget>().Use<AWidget>();

                _.IncludeRegistry<ImportantClientServices>();
            });

            container.GetInstance<IWidget>()
                .ShouldBeOfType<ImportantClientWidget>();

            Debug.WriteLine(container.WhatDoIHave(pluginType: typeof(IWidget)));
        }
开发者ID:khellang,项目名称:structuremap,代码行数:14,代码来源:clear_all.cs

示例12: SetUp

        public void SetUp()
        {
            AssetContentEndpoint.Latched = true;
            AssetDeclarationVerificationActivator.Latched = true;

            registry = new FubuRegistry(x =>
            {
                x.Actions.IncludeTypes(t => false);

                x.Route("area/sub/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/prop")
                    .Calls<TestController>(c => c.SomeAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub2/{Name}")
                    .Calls<TestController>(c => c.ThirdAction(null)).OutputToJson();

                x.Route("area/sub3/{Name}/{Age}")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();

                x.Route("area/sub4/some_pattern")
                    .Calls<TestController>(c => c.AnotherAction(null)).OutputToJson();
            });

            container = new Container(x =>
            {
                x.For<IStreamingData>().Use(MockRepository.GenerateMock<IStreamingData>());
                x.For<ICurrentChain>().Use(new CurrentChain(null, null));
                x.For<ICurrentHttpRequest>().Use(new StubCurrentHttpRequest{
                    TheApplicationRoot = "http://server"
                });
            });

            routes = FubuApplication.For(registry)
                .StructureMap(container)
                .Bootstrap()
                .Routes
                .Where(r => !r.As<Route>().Url.StartsWith("_content"))
                .ToList();

            container.Configure(x => x.For<IOutputWriter>().Use(new InMemoryOutputWriter()));
            Debug.WriteLine(container.WhatDoIHave());
        }
开发者ID:andreasohlund,项目名称:fubumvc,代码行数:47,代码来源:FubuBootstrapperIntegrationTester.cs

示例13: use_a_custom_policy

        public void use_a_custom_policy()
        {
            var container = new Container(_ =>
            {
                _.For<IRepository>().Use<NormalRepository>();

                _.Policies.Add<SpecialGuyGetsSpecialRepository>();
            });

            Debug.WriteLine(container.WhatDoIHave());

            // Policy should not apply to NormalGuy
            container.GetInstance<NormalGuy>().Repository.ShouldBeOfType<NormalRepository>();

            // Policy should override the repository dependency of SpecialGuy
            container.GetInstance<SpecialGuy>().Repository.ShouldBeOfType<SpecialRepository>();
        }
开发者ID:slahn,项目名称:structuremap,代码行数:17,代码来源:CustomPolicyTester.cs

示例14: Main

        private static void Main(string[] args)
        {
            var container = new Container(x =>
            {
                x.Scan(s =>
                {
                    s.TheCallingAssembly();
                    s.WithDefaultConventions();
                });
                x.ForRequestedType<IDoMore<string>>().TheDefaultIsConcreteType<DoForStrings>();
                x.ForRequestedType<IDoThat>().AddInstances(i =>
                {
                    i.OfConcreteType<DoThat>().WithName("Red");
                    i.OfConcreteType<DoThat>().WithName("Blue");
                });
            });

            ObjectFactory.Initialize(i => i.ForRequestedType<IDoThat>().TheDefaultIsConcreteType<DoThat>());
            Debug.WriteLine(container.WhatDoIHave());

            ContainerDetail details = ContainerVisualizerObjectSource.BuildContainerDetails(container);
            Application.Run(new ContainerForm(details));
        }
开发者ID:hp4711,项目名称:structuremap,代码行数:23,代码来源:Program.cs

示例15: Application_Start

    protected void Application_Start()
    {
      Container = new Container(new FileRegistry(HostingEnvironment.ApplicationPhysicalPath));

      LogService.Info("Application is starting");

      ViewEngines.Engines.Clear();
      //default view engine
      ViewEngines.Engines.Add(new ThemeViewEngine());

      //use IoC controller factory
      ControllerBuilder.Current.SetControllerFactory(typeof(DynamicControllerFactory));

      //modularity
      PluginEngine.LoadPlugins(Container, RouteTable.Routes, ViewEngines.Engines, ModelBinders.Binders, Server.MapPath("~/"), Server.MapPath("~/bin"));

      //default route
      RouteTable.Routes.MapRoute("Default", @"{controller}/{action}");
      Container.Inject<RouteCollection>(RouteTable.Routes);
      LogService.Debug(Container.WhatDoIHave());

      LogService.Info("Cache size bytes={0} percent used={1}", HttpRuntime.Cache.EffectivePrivateBytesLimit, HttpRuntime.Cache.EffectivePercentagePhysicalMemoryLimit);
    }
开发者ID:erikzaadi,项目名称:atomsitethemes.erikzaadi.com,代码行数:23,代码来源:ServerApp.cs


注:本文中的Container.WhatDoIHave方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。