本文整理汇总了C#中TypeMapper.FromType方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMapper.FromType方法的具体用法?C# TypeMapper.FromType怎么用?C# TypeMapper.FromType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TypeMapper
的用法示例。
在下文中一共展示了TypeMapper.FromType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TransformedType_RequiredProperties_ReturnsRequiredProperties
public void TransformedType_RequiredProperties_ReturnsRequiredProperties()
{
var mapper = new TypeMapper(new CritterPomonaConfiguration());
var type = mapper.FromType(typeof(Planet));
var requiredProperties = type.RequiredProperties.ToList();
Assert.That(requiredProperties.All(x => x.IsRequiredForConstructor), Is.True);
}
示例2: MatchChildren_FromRootRoute_IsSuccessful
MatchChildren_FromRootRoute_IsSuccessful()
{
// Route might be dependant on parent node, for example: PigTail GetTail(Pig pig)
// ..or it might not be: PigTail GetTail(int peonId, int animalId) <-- We need to make sure animal is of type Pig before invoking Route
// WHEN ROUTE IS AMBIGUOUS BY TYPE, WE ALWAYS NEED TO FETCH THE LAST SINGLE-RESOURCE NODE, OR AT LEAST DETERMINE TYPE
var tm = new TypeMapper(new Config());
var root = new RootRoute((ResourceType)tm.FromType<Root>());
var allNodes = root.WrapAsEnumerable<Route>().Flatten(x => x.Children).ToList();
RouteMatchTree routeMatchTree = new RouteMatchTree(root, "peons/fillifjonka/animals/1234/tail/end",
Substitute.For<IPomonaSession>());
routeMatchTree.Leafs.ForEach(Console.WriteLine);
var match1 = routeMatchTree.Root;
Assert.That(match1.SelectedFinalMatch, Is.Null);
var fork = match1.NextFork();
fork.SelectedChild = fork.Children.First();
Console.WriteLine(match1.SelectedFinalMatch);
Console.WriteLine(match1);
}
示例3: FromEnumType_ReturnsEnumTypeSpec
public void FromEnumType_ReturnsEnumTypeSpec()
{
var mapper = new TypeMapper(new CritterPomonaConfiguration());
Assert.That(mapper.FromType<CustomEnum>(), Is.InstanceOf<EnumTypeSpec>());
}