本文整理汇总了C#中System.Condition.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Condition.Clone方法的具体用法?C# Condition.Clone怎么用?C# Condition.Clone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Condition
的用法示例。
在下文中一共展示了Condition.Clone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestClone
public void TestClone()
{
Condition condition = new Condition(Guid.NewGuid(), "className", new TranslateableLanguageItem(Guid.NewGuid()), OperatorType.Equals, false);
condition.DataLeft = new DataElement(Guid.NewGuid(), new TranslateableLanguageItem(), new TranslateableLanguageItem("DataLeft"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem(Guid.NewGuid()), DataType.String, "data"), false);
condition.DataRight = new DataElement(Guid.NewGuid(), new TranslateableLanguageItem(), new TranslateableLanguageItem("DataRight"), DataType.String, DataItem.CreateDataItem(new TranslateableLanguageItem(Guid.NewGuid()), DataType.String, "data"), false);
Condition copy = condition.Clone() as Condition;
Assert.IsNotNull(copy);
Assert.AreNotEqual(condition.Identifier, copy.Identifier);
Assert.AreEqual(condition.Class, copy.Class);
Assert.AreNotEqual(condition.Name.Identifier, copy.Name.Identifier);
Assert.AreEqual(condition.Name.Value, copy.Name.Value);
Assert.AreEqual(condition.Operator, copy.Operator);
Assert.AreEqual(condition.Parent, copy.Parent);
Assert.AreEqual(condition.ReadOnly, copy.ReadOnly);
Assert.IsNotNull(copy.DataLeft);
Assert.AreEqual(condition.DataLeft.DisplayName.Value, copy.DataLeft.DisplayName.Value);
Assert.AreNotEqual(condition.DataLeft.Identifier, copy.DataLeft.Identifier);
Assert.AreNotEqual(condition.DataLeft.Name.Identifier, copy.DataLeft.Name.Identifier);
Assert.AreEqual(condition.DataLeft.Name.Value, copy.DataLeft.Name.Value);
Assert.AreEqual(condition.DataLeft.ReadOnly, copy.DataLeft.ReadOnly);
Assert.AreEqual(condition.DataLeft.Type, copy.DataLeft.Type);
DataItem conditionItem = condition.DataLeft.Data as DataItem;
DataItem copyItem = copy.DataLeft.Data as DataItem;
Assert.AreEqual(conditionItem.Name.Value, copyItem.Name.Value);
Assert.AreEqual(conditionItem.ReadOnly, copyItem.ReadOnly);
Assert.AreEqual(conditionItem.Value, copyItem.Value);
Assert.IsNotNull(copy.DataRight);
Assert.AreEqual(condition.DataRight.DisplayName.Value, copy.DataRight.DisplayName.Value);
Assert.AreNotEqual(condition.DataRight.Identifier, copy.DataRight.Identifier);
Assert.AreEqual(condition.DataRight.Name.Value, copy.DataRight.Name.Value);
Assert.AreEqual(condition.DataRight.ReadOnly, copy.DataRight.ReadOnly);
Assert.AreEqual(condition.DataRight.Type, copy.DataRight.Type);
conditionItem = condition.DataRight.Data as DataItem;
copyItem = copy.DataRight.Data as DataItem;
Assert.AreEqual(conditionItem.Name.Value, copyItem.Name.Value);
Assert.AreEqual(conditionItem.ReadOnly, copyItem.ReadOnly);
Assert.AreEqual(conditionItem.Value, copyItem.Value);
}
示例2: TestClone_DataLeft_DataSource
public void TestClone_DataLeft_DataSource()
{
Condition condition = new Condition(Guid.NewGuid(), "className", new TranslateableLanguageItem(Guid.NewGuid()), OperatorType.Equals, false);
DataMethod method = new DataMethod("dataMethod");
DataSource source = new DataSource("source.assembly", "source.class", method);
DataElement item = new DataElement(
Guid.NewGuid(),
new TranslateableLanguageItem(),
new TranslateableLanguageItem("DataLeft"),
DataType.Object,
source
);
condition.DataLeft = item;
Condition copyCondition = condition.Clone() as Condition;
Assert.IsNotNull(copyCondition);
Assert.IsNotNull(copyCondition.DataLeft);
Assert.IsNotNull(item.Data as DataSource);
}