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