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


C# Context.GetComponent方法代码示例

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


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

示例1: TestGetComponentByNameAndType

        public void TestGetComponentByNameAndType()
        {
            using (Context context = new Context())
            {
                context.Scan("TestSimple.Namespace")
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                Assert.IsNotNull(context.GetComponent("TestClass1", typeof(TestClass1)));
                Assert.IsTrue(context.GetComponent("TestClass1", typeof(TestClass1)) is TestClass1);
            }
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:13,代码来源:ContextTest.cs

示例2: TestGetComponentByNameAndTypeGeneric

        public void TestGetComponentByNameAndTypeGeneric()
        {
            using (Context context = new Context())
            {
                context.Scan("TestSimple.Namespace")
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                Assert.IsNotNull(context.GetComponent<TestClass1>("TestClass1"));
            }
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:12,代码来源:ContextTest.cs

示例3: TestScanWithCyclicInjection

        public void TestScanWithCyclicInjection()
        {
            using (Context context = new Context())
            {
                context.Scan("TestCyclic.Namespace")
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                Assert.AreEqual(2, context.GetComponents().Count);
                Assert.IsNotNull(context.GetComponent<TestCyclicClass1>());
                Assert.IsNotNull(context.GetComponent<TestCyclicClass2>());
                Assert.AreEqual(context.GetComponent<TestCyclicClass1>().ReferencedTestClass, context.GetComponent<TestCyclicClass2>());
                Assert.AreEqual(context.GetComponent<TestCyclicClass2>().ReferencedTestClass, context.GetComponent<TestCyclicClass1>());
            }
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:16,代码来源:ContextTest.cs

示例4: TestScanUsingType

        public void TestScanUsingType()
        {
            using (Context context = new Context())
            {
                context.Scan(typeof(TestClass1))
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                Assert.AreEqual(2, context.GetComponents().Count);
                Assert.IsNotNull(context.GetComponent<TestClass1>());
                Assert.IsNotNull(context.GetComponent<TestClass2>());
                Assert.AreEqual(context.GetComponent<TestClass1>().ReferencedTestClass, context.GetComponent<TestClass2>());
            }
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:15,代码来源:ContextTest.cs

示例5: TestRegisterUsingGenerics

        public void TestRegisterUsingGenerics()
        {
            using (Context context = new Context())
            {
                context.Register<TestClass1>()
                        .Register<TestClass2>()
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                Assert.AreEqual(2, context.GetComponents().Count);
                Assert.IsNotNull(context.GetComponent<TestClass1>());
                Assert.IsNotNull(context.GetComponent<TestClass2>());
                Assert.AreEqual(context.GetComponent<TestClass1>().ReferencedTestClass, context.GetComponent<TestClass2>());
            }
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:16,代码来源:ContextTest.cs

示例6: TestLifecycle

        public void TestLifecycle()
        {
            TestLifecycleClass obj = null;

            using (Context context = new Context())
            {
                context.Scan<TestLifecycleClass>()
                        .Start();

                Assert.AreEqual(ContextState.Started, context.State);

                obj = context.GetComponent<TestLifecycleClass>();

                Assert.IsNotNull(obj);
                Assert.IsTrue(obj.OnStartInvoked);
                Assert.IsFalse(obj.OnStopInvoked);
            }

            Assert.IsTrue(obj.OnStartInvoked);
            Assert.IsTrue(obj.OnStopInvoked);
        }
开发者ID:arenanet,项目名称:sprout-ioc,代码行数:21,代码来源:ContextTest.cs


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