本文整理汇总了C#中Context.Scan方法的典型用法代码示例。如果您正苦于以下问题:C# Context.Scan方法的具体用法?C# Context.Scan怎么用?C# Context.Scan使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context.Scan方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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"));
}
}
示例3: TestScanUsingTypeInvalidState_Error
public void TestScanUsingTypeInvalidState_Error()
{
using (Context context = new Context())
{
context.Start();
context.Scan(typeof(TestClass1));
}
}
示例4: 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>());
}
}
示例5: 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>());
}
}
示例6: TestScanUsingTypeComponentName_Error
public void TestScanUsingTypeComponentName_Error()
{
using (Context context = new Context())
{
context.Scan(typeof(TestComponentNameClass1));
}
}
示例7: TestScanUsingNamespaceInvalidState_Error
public void TestScanUsingNamespaceInvalidState_Error()
{
using (Context context = new Context())
{
context.Start();
context.Scan("TestComponentName.Namespace");
}
}
示例8: TestScanUsingNamespaceComponentName_Error
public void TestScanUsingNamespaceComponentName_Error()
{
using (Context context = new Context())
{
context.Scan("TestComponentName.Namespace");
}
}
示例9: TestScanUsingGenericsInvalidState_Error
public void TestScanUsingGenericsInvalidState_Error()
{
using (Context context = new Context())
{
context.Start();
context.Scan<TestClass1>();
}
}
示例10: TestScanUsingGenericsComponentName_Error
public void TestScanUsingGenericsComponentName_Error()
{
using (Context context = new Context())
{
context.Scan<TestComponentNameClass1>();
}
}
示例11: 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);
}