本文整理汇总了C#中Metadata.MetadataAs方法的典型用法代码示例。如果您正苦于以下问题:C# Metadata.MetadataAs方法的具体用法?C# Metadata.MetadataAs怎么用?C# Metadata.MetadataAs使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Metadata
的用法示例。
在下文中一共展示了Metadata.MetadataAs方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ConvertStringArrayToIntArray
public void ConvertStringArrayToIntArray()
{
// Given
Engine engine = new Engine();
Metadata metadata = new Metadata(engine);
// When
metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new string[] { "1", "2", "3" }) });
IMetadata<int[]> metadataAs = metadata.MetadataAs<int[]>();
// Then
CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, (IEnumerable)metadata["A"]);
CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadataAs["A"]);
}
示例2: ConvertIntToString
public void ConvertIntToString()
{
// Given
Engine engine = new Engine();
Metadata metadata = new Metadata(engine);
// When
metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", 1) });
IMetadata<string> metadataAs = metadata.MetadataAs<string>();
// Then
Assert.AreEqual(1, metadata["A"]);
Assert.AreEqual("1", metadataAs["A"]);
}
示例3: ConvertIntArrayToStringEnumerable
public void ConvertIntArrayToStringEnumerable()
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
Metadata metadata = new Metadata(engine);
// When
metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", new int[] { 1, 2, 3 }) });
IMetadata<IEnumerable<string>> metadataAs = metadata.MetadataAs<IEnumerable<string>>();
// Then
CollectionAssert.AreEqual(new int[] { 1, 2, 3 }, (IEnumerable)metadata["A"]);
CollectionAssert.AreEqual(new string[] { "1", "2", "3" }, metadataAs["A"]);
}
示例4: ConvertStringToIntArray
public void ConvertStringToIntArray()
{
// Given
Engine engine = new Engine();
engine.Trace.AddListener(new TestTraceListener());
Metadata metadata = new Metadata(engine);
// When
metadata = metadata.Clone(new[] { new KeyValuePair<string, object>("A", "1") });
IMetadata<int[]> metadataAs = metadata.MetadataAs<int[]>();
// Then
Assert.AreEqual("1", metadata["A"]);
CollectionAssert.AreEqual(new int[] { 1 }, (IEnumerable)metadataAs["A"]);
}