當前位置: 首頁>>代碼示例>>C#>>正文


C# Condition.Clone方法代碼示例

本文整理匯總了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);
        }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:47,代碼來源:TestCondition.cs

示例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);
        }
開發者ID:killbug2004,項目名稱:WSProf,代碼行數:22,代碼來源:TestCondition.cs


注:本文中的System.Condition.Clone方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。