当前位置: 首页>>代码示例>>C#>>正文


C# TypeMapper.DeepClone方法代码示例

本文整理汇总了C#中TypeMapper.DeepClone方法的典型用法代码示例。如果您正苦于以下问题:C# TypeMapper.DeepClone方法的具体用法?C# TypeMapper.DeepClone怎么用?C# TypeMapper.DeepClone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TypeMapper的用法示例。


在下文中一共展示了TypeMapper.DeepClone方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: HandlesCircularReferences__ObjectReferencesSelfDirectly

        public void HandlesCircularReferences__ObjectReferencesSelfDirectly()
        {
            var n = new LinkedListNode { Id = 13 };
            n.Next = n;
            n.Previous = n;

            var tm = new TypeMapper();

            var clone = tm.DeepClone<LinkedListNode>(n);

            Assert.AreEqual(13, clone.Id);
            Assert.AreSame(n, n.Next);
            Assert.AreSame(n, n.Previous);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:14,代码来源:TypeMapper.DeepClone.tests.cs

示例2: CanCloneAnObject

        public void CanCloneAnObject()
        {
            var st = new SimpleType();
            st.EnumProperty = DayOfWeek.Friday;
            st.IntegerProperty = 13;
            st.StringProperty = "some string";

            var tm = new TypeMapper();

            var clone = tm.DeepClone<SimpleType>(st);

            Assert.AreEqual(st.EnumProperty, clone.EnumProperty);
            Assert.AreEqual(st.IntegerProperty, clone.IntegerProperty);
            Assert.AreEqual(st.StringProperty, clone.StringProperty);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:15,代码来源:TypeMapper.DeepClone.tests.cs

示例3: Bug001__MapToInterfaceProperty

        public void Bug001__MapToInterfaceProperty()
        {
            var c1 = new Bug001_Class();
            c1.Id = 1;
            c1.Property = new Bug001_Class();
            c1.Property.Id = 2;

            var tm = new TypeMapper();

            var clone = tm.DeepClone(c1);

            Assert.IsNotNull(clone);
            Assert.AreEqual(clone.Id, c1.Id);
            Assert.AreEqual(clone.Property.Id, c1.Property.Id);
            Assert.IsNull(clone.Property.Property);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:16,代码来源:TypeMapper._BugFixes.cs

示例4: CanCloneToSubType

        public void CanCloneToSubType()
        {
            var st = new SimpleType2();
            st.EnumProperty = DayOfWeek.Friday;
            st.IntegerProperty = 13;
            st.StringProperty = "some string";
            st.AnotherProperty = 1;

            var tm = new TypeMapper();

            // clone SimpleType2 to its subtype SimpleType
            var clone = tm.DeepClone<SimpleType>(st);

            Assert.AreEqual(st.EnumProperty, clone.EnumProperty);
            Assert.AreEqual(st.IntegerProperty, clone.IntegerProperty);
            Assert.AreEqual(st.StringProperty, clone.StringProperty);

            Assert.IsFalse(clone is SimpleType2);
            Assert.IsTrue(clone is SimpleType);        
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:20,代码来源:TypeMapper.DeepClone.tests.cs

示例5: Bug005__CloneDataTable__NotSupported_Thrown

        public void Bug005__CloneDataTable__NotSupported_Thrown()
        {
            var dt = new DataTable();
            dt.Columns.Add("str", typeof(string));
            dt.Columns.Add("int", typeof(int));

            dt.Rows.Add("one", 1);
            dt.Rows.Add("two", 2);

            var tm = new TypeMapper();  

            var clone = tm.DeepClone(dt);

            Assert.IsNotNull(clone);
            Assert.AreEqual(dt.Rows.Count, clone.Rows.Count);
            Assert.AreEqual(dt.Columns.Count, clone.Columns.Count);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:17,代码来源:TypeMapper._BugFixes.cs

示例6: HandlesCircularReferences__ObjectReferencesSelfIndirectly

        public void HandlesCircularReferences__ObjectReferencesSelfIndirectly()
        {
            var n0 = new LinkedListNode { Id = 0 };
            var n1 = new LinkedListNode { Id = 1 };
            var n2 = new LinkedListNode { Id = 2 };
            var n3 = new LinkedListNode { Id = 3 };

            n0.Next = n1;
            n1.Next = n2;
            n2.Next = n3;
            n3.Next = n0;

            n0.Previous = n3;
            n1.Previous = n0;
            n2.Previous = n1;
            n3.Previous = n2;

            var tm = new TypeMapper();

            var clone = tm.DeepClone<LinkedListNode>(n3);

            Assert.AreEqual(3, clone.Id);

            Assert.AreEqual(2, clone.Previous.Id);
            Assert.AreEqual(1, clone.Previous.Previous.Id);
            Assert.AreEqual(0, clone.Previous.Previous.Previous.Id);
            Assert.AreEqual(3, clone.Previous.Previous.Previous.Previous.Id);

            Assert.AreEqual(0, clone.Next.Id);
            Assert.AreEqual(1, clone.Next.Next.Id);
            Assert.AreEqual(2, clone.Next.Next.Next.Id);
            Assert.AreEqual(3, clone.Next.Next.Next.Next.Id);

            Assert.AreSame(clone, clone.Next.Next.Next.Next);
            Assert.AreSame(clone, clone.Previous.Previous.Previous.Previous);
        }
开发者ID:squaredinfinity,项目名称:Foundation,代码行数:36,代码来源:TypeMapper.DeepClone.tests.cs


注:本文中的TypeMapper.DeepClone方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。