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


C# ODocument.Serialize方法代码示例

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


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

示例1: ShouldSerializeNumbers

        public void ShouldSerializeNumbers()
        {
            string recordString = "[email protected]:123b,ShortNumber:1234s,IntNumber:123456,LongNumber:12345678901l,FloatNumber:3.14f,DoubleNumber:3.14d,DecimalNumber:1234567.8901c,embedded:(ByteNumber:123b,ShortNumber:1234s,IntNumber:123456,LongNumber:12345678901l,FloatNumber:3.14f,DoubleNumber:3.14d,DecimalNumber:1234567.8901c)";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("ByteNumber", byte.Parse("123"))
                .SetField("ShortNumber", short.Parse("1234"))
                .SetField("IntNumber", 123456)
                .SetField("LongNumber", 12345678901)
                .SetField("FloatNumber", 3.14f)
                .SetField("DoubleNumber", 3.14)
                .SetField("DecimalNumber", new Decimal(1234567.8901))
                .SetField("embedded.ByteNumber", byte.Parse("123"))
                .SetField("embedded.ShortNumber", short.Parse("1234"))
                .SetField("embedded.IntNumber", 123456)
                .SetField("embedded.LongNumber", 12345678901)
                .SetField("embedded.FloatNumber", 3.14f)
                .SetField("embedded.DoubleNumber", 3.14)
                .SetField("embedded.DecimalNumber", new Decimal(1234567.8901));

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:25,代码来源:RecordSerializationTests.cs

示例2: ShouldSerializeNull

        public void ShouldSerializeNull()
        {
            string recordString = "[email protected]:,embedded:(null:)";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField<object>("null", null)
                .SetField<object>("embedded.null", null);

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:13,代码来源:RecordSerializationTests.cs

示例3: ShouldNotSerializeFieldsWithAtCharacter

        public void ShouldNotSerializeFieldsWithAtCharacter()
        {
            string recordString = "[email protected]:true";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("@ClassId", 123)
                .SetField("@Foo", "bar")
                .SetField("@ORID", new ORID(8, 0))
                .SetField<bool>("foo", true);

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:15,代码来源:RecordSerializationTests.cs

示例4: ShouldSerializeBoolean

        public void ShouldSerializeBoolean()
        {
            string recordString = "[email protected]:true,isFalse:false,embedded:(isTrue:true,isFalse:false),array:[true,false]";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("isTrue", true)
                .SetField("isFalse", false)
                .SetField("embedded.isTrue", true)
                .SetField("embedded.isFalse", false)
                .SetField<List<bool>>("array", new List<bool> { true, false });

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:16,代码来源:RecordSerializationTests.cs

示例5: ShouldSerializeDateTime

        public void ShouldSerializeDateTime()
        {
            DateTime dateTime = DateTime.Now;

            // get Unix time version
            DateTime unixEpoch = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
            string timeString = ((long)((DateTime)dateTime - unixEpoch).TotalMilliseconds).ToString();

            string recordString = "[email protected]:" + timeString + "t,embedded:(DateTime:" + timeString + "t)";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("DateTime", dateTime)
                .SetField("embedded.DateTime", dateTime);

            string serializedRecord = document.Serialize();

            Assert.AreEqual(serializedRecord, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:19,代码来源:RecordSerializationTests.cs

示例6: ShouldSerializeSetOfORIDs

        public void ShouldSerializeSetOfORIDs()
        {
            string recordString = "[email protected]:#8:0,Set:<#8:1,#8:2>,embedded:(Set:<#9:1,#9:2>)";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("Single", new ORID(8, 0))
                .SetField("Set", new HashSet<ORID> { new ORID(8, 1), new ORID(8, 2) })
                .SetField("embedded.Set", new HashSet<ORID> { new ORID(9, 1), new ORID(9, 2) });

            string serializedString = document.Serialize();

            Assert.AreEqual(serializedString, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:14,代码来源:RecordSerializationTests.cs

示例7: ShouldSerializeListOfORIDs

        public void ShouldSerializeListOfORIDs()
        {
            string recordString = "[email protected]:#8:0,Array:[#8:1,#8:2],embedded:(Array:[#9:1,#9:2])";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("Single", new ORID(8, 0))
                .SetField("Array", new List<ORID> { new ORID(8, 1), new ORID(8, 2) })
                .SetField("embedded.Array", new List<ORID> { new ORID(9, 1), new ORID(9, 2) });

            string serializedString = document.Serialize();

            Assert.AreEqual(serializedString, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:14,代码来源:RecordSerializationTests.cs

示例8: ShouldSerializeStrings

        public void ShouldSerializeStrings()
        {
            string recordString = "[email protected]:\"Bra\\" + "\"vo \\\\ asdf\",Array:[\"foo\",\"bar\"],embedded:(String:\"Bra\\" + "\"vo \\\\ asdf\",Array:[\"foo\",\"bar\"])";

            ODocument document = new ODocument()
                .SetField("@ClassName", "TestClass")
                .SetField("String", "Bra\"vo \\ asdf")
                .SetField("Array", new List<string> { "foo", "bar" })
                .SetField("embedded.String", "Bra\"vo \\ asdf")
                .SetField("embedded.Array", new List<string> { "foo", "bar" });

            string serializedString = document.Serialize();

            Assert.AreEqual(serializedString, recordString);
        }
开发者ID:jocull,项目名称:OrientDB-NET.binary,代码行数:15,代码来源:RecordSerializationTests.cs


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