本文整理汇总了C#中BuildInfo.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# BuildInfo.GetType方法的具体用法?C# BuildInfo.GetType怎么用?C# BuildInfo.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BuildInfo
的用法示例。
在下文中一共展示了BuildInfo.GetType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterTest
public void RegisterTest()
{
//注册空的Component,抛出异常
IComponent expected = null;
IComponent actual = null;
bool ret = false;
try
{
ComponentManager.Current.Register(expected);
}
catch (Exception)
{
ret = true;
}
Assert.IsTrue(ret);
//注册同一命名空间下的BuidInfo
expected = new BuildInfo();
ComponentManager.Current.Register(expected);
var components = ComponentManager.Current.GetCollection();
Assert.AreEqual(components.Components.Count, 2);
//说明注册进去了
actual = ComponentManager.Current.GetComponent(expected.GetType().Name.ToLowerInvariant());
Assert.IsInstanceOfType(actual, expected.GetType());
//注册不同命名空间下的BuidInfo
expected = new Arch.CFramework.AppInternals.Test.TestBean.BuildInfo();
ComponentManager.Current.Register(expected);
components = ComponentManager.Current.GetCollection();
Assert.AreEqual(components.Components.Count, 3);
//说明注册进去了
//actual = ComponentManager.Current.GetComponent(expected.GetType().Name.ToLowerInvariant());
//Assert.IsInstanceOfType(actual, expected.GetType());
}
示例2: GetComponentsTest
public void GetComponentsTest()
{
ComponentContainer_Accessor target = new ComponentContainer_Accessor(); // TODO: Initialize to an appropriate value
IEnumerable<IComponent> actual;
//容器中注册两个容器
IComponent component1 = new HostInfo();
IComponent component2 = new BuildInfo();
target.Register(component1);
target.Register(component2);
actual = target.GetComponents();
//actual不为空
Assert.IsNotNull(actual);
//actual个数为2
int result=0;
using (IEnumerator<IComponent> enumerator = actual.GetEnumerator())
{
while (enumerator.MoveNext())
result++;
}
Assert.AreEqual(result, 2);
//actual中含有HostInfo和BuildInfo
bool ret=false;
using (IEnumerator<IComponent> enumerator = actual.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.GetType().Name.Equals(component1.GetType().Name))
{
ret = true; break;
}
}
}
Assert.IsTrue(ret);
ret = false;
using (IEnumerator<IComponent> enumerator = actual.GetEnumerator())
{
while (enumerator.MoveNext())
{
if (enumerator.Current.GetType().Name.Equals(component2.GetType().Name))
{
ret = true; break;
}
}
}
Assert.IsTrue(ret);
}