本文整理汇总了C#中Cat.GetType方法的典型用法代码示例。如果您正苦于以下问题:C# Cat.GetType方法的具体用法?C# Cat.GetType怎么用?C# Cat.GetType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cat
的用法示例。
在下文中一共展示了Cat.GetType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Should_request_respond_with_correct_message_types
public void Should_request_respond_with_correct_message_types()
{
bus.Respond<IAnimal, IAnimal>(@interface =>
{
var cat = @interface as Cat;
var dog = @interface as Dog;
if (cat != null)
{
Console.Out.WriteLine("Name = {0}", cat.Name);
Console.Out.WriteLine("Meow = {0}", cat.Meow);
}
else if (dog != null)
{
Console.Out.WriteLine("Name = {0}", dog.Name);
Console.Out.WriteLine("Bark = {0}", dog.Bark);
}
else
{
Console.Out.WriteLine("message was not a dog or a cat");
}
return @interface;
});
Thread.Sleep(500);
IAnimal request = new Cat
{
Name = "Gobbolino",
Meow = "Purr"
};
IAnimal response = bus.Request<IAnimal, IAnimal>(request);
Assert.AreEqual(request.Name, response.Name);
Assert.AreSame(request.GetType(), response.GetType());
}