本文整理汇总了C#中DataItem.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# DataItem.DeepClone方法的具体用法?C# DataItem.DeepClone怎么用?C# DataItem.DeepClone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataItem
的用法示例。
在下文中一共展示了DataItem.DeepClone方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Clone
public void Clone()
{
DataItem di = new DataItem(9,"name",typeof(int),DataItemRole.Output,"tag");
di.Id = 5;
DataItem clone = (DataItem) di.DeepClone();
//be sure the id gets reset
Assert.AreEqual(0,clone.Id);
Assert.AreEqual(di.Value,clone.Value);
Assert.AreEqual(di.Name, clone.Name);
Assert.AreEqual(di.ValueType, clone.ValueType);
Assert.AreEqual(di.Role, clone.Role);
Assert.AreEqual(di.Tag, clone.Tag);
}
示例2: CloneLinkedDataItem
public void CloneLinkedDataItem()
{
var dataItem = new DataItem();
dataItem.Value = new CloneableClassWithThreeProperties();
//TODO: why do we need to set the valuetype. Why is this not Typeof(value)???
//or (next best) why is this determined at construction time.
dataItem.ValueType = typeof (CloneableClassWithThreeProperties);
IDataItem linkedDataItem = new DataItem();
linkedDataItem.ValueType = typeof(CloneableClassWithThreeProperties);
linkedDataItem.LinkTo(dataItem);
Assert.AreEqual(dataItem.ValueType,linkedDataItem.ValueType);
//action! clone the linked dataitem
var clonedLinkedDataItem = (DataItem)linkedDataItem.DeepClone();
Assert.AreEqual(linkedDataItem.ValueType,clonedLinkedDataItem.ValueType );
}
示例3: CloneShouldNotCausePropertyChangeOnSourceValue
public void CloneShouldNotCausePropertyChangeOnSourceValue()
{
//set a nameable property changing class in the dataItem
var propertyChangingClass = new CloneableClassWithThreeProperties();
var dataItem = new DataItem(propertyChangingClass);
propertyChangingClass.PropertyChanged += delegate
{
Assert.Fail("Clone should not cause a change in the source!");
};
//action clone the dataitem.
dataItem.DeepClone();
}
示例4: CloneNotCloneableValueObject
public void CloneNotCloneableValueObject()
{
IDataItem dataItem = new DataItem();
dataItem.Value = mocks.Stub<IFileBased>();
var clone = (DataItem)dataItem.DeepClone();
}