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


C# SerializationWriter类代码示例

本文整理汇总了C#中SerializationWriter的典型用法代码示例。如果您正苦于以下问题:C# SerializationWriter类的具体用法?C# SerializationWriter怎么用?C# SerializationWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Serialize

            public byte[] Serialize()
            {
                var _SerializationWriter = new SerializationWriter();
                _SerializationWriter.WriteString(ThrowedException);

                return _SerializationWriter.ToArray();
            }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:NException_UnhandledExceptionInsideAThread.cs

示例2: Serialize

            public byte[] Serialize()
            {
                var _SerializationWriter = new SerializationWriter();
                _SerializationWriter.WriteString(Message);

                return _SerializationWriter.ToArray();
            }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:NDatabaseMisc.cs

示例3: Serialize

            public byte[] Serialize()
            {
                var _SerializationWriter = new SerializationWriter();
                _SerializationWriter.WriteUInt32(NumberOfQueueEntries);

                return _SerializationWriter.ToArray();
            }
开发者ID:TheByte,项目名称:sones,代码行数:7,代码来源:NStorageEngine_WriteQueueFull.cs

示例4: Serialize

		public static void Serialize(SerializationWriter writer, Color color)
		{
			BitVector32 flags = new BitVector32();

			if (color.IsKnownColor)
				flags[ColorIsKnown] = true;
			else if (color.IsNamedColor)
				flags[ColorHasName] = true;
			else if (!color.IsEmpty)
			{
				flags[ColorHasValue] = true;
				flags[ColorHasRed] = color.R != 0;
				flags[ColorHasGreen] = color.G != 0;
				flags[ColorHasBlue] = color.B != 0;
				flags[ColorHasAlpha] = color.A != 0;
			}
			writer.WriteOptimized(flags);

			if (color.IsKnownColor)
				writer.WriteOptimized((int) color.ToKnownColor());
			else if (color.IsNamedColor)
				writer.WriteOptimized(color.Name);
			else if (!color.IsEmpty)
			{
				byte component;
				if ( (component = color.R) != 0) writer.Write(component);	
				if ( (component = color.G) != 0) writer.Write(component);	
				if ( (component = color.B) != 0) writer.Write(component);	
				if ( (component = color.A) != 0) writer.Write(component);	
			}
		}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:31,代码来源:DrawingFastSerializationHelper.cs

示例5: Serialize

            public Byte[] Serialize()
            {
                var _SerializationWriter = new SerializationWriter();

                _SerializationWriter.WriteString(ObjectLocation);
                _SerializationWriter.WriteByte(NewDefaultRule);

                return _SerializationWriter.ToArray();
            }
开发者ID:TheByte,项目名称:sones,代码行数:9,代码来源:NAccessControl_DefaultRuleChanged.cs

示例6: GetObjectData

		public virtual void GetObjectData(SerializationInfo info, StreamingContext context)
		{
			using (SerializationWriter writer = new SerializationWriter())
			{
				writer.Write(_name);
				writer.WriteObject(_dataType);
				writer.WriteObject(_value);
				info.AddValue("d", writer.ToArray());
			}

		}
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:11,代码来源:UserOption.cs

示例7: Serialize

        public byte[] Serialize()
        {
            SerializationWriter writer = new SerializationWriter();

            writer.WriteObject(AccountName);
            writer.WriteObject(DeviceID);
			writer.WriteObject(Timestamp);
			writer.WriteObject(Latitude);
			writer.WriteObject(Longitude);
			writer.WriteObject(AccuracyInMeters);

            return writer.ToArray();
        }
开发者ID:pereritob,项目名称:hacs,代码行数:13,代码来源:MiataruDataObject.cs

示例8: TestNull

        public void TestNull()
        {
            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms))
            using (SerializationReader sr = new SerializationReader(ms))
            {
                sw.Write<object>(null);

                sw.Write<int[]>(null);
                sw.Write<List<int>>(null);
                sw.Write<Dictionary<int, string>>(null);

                sw.Write<TestSerializable>(null);
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:15,代码来源:RangeTests.cs

示例9: TestUTF16Chars

        public void TestUTF16Chars()
        {
            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms, new UnicodeEncoding()))
            using (SerializationReader sr = new SerializationReader(ms, new UnicodeEncoding()))
            {
                for (int i = 0; i < 55296; i++)
                    sw.Write((char)i);

                sw.Flush();
                ms.Position = 0;

                for (int i = 0; i < 55296; i++)
                    Assert.AreEqual((char)i, sr.Read<char>());
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:16,代码来源:StringTests.cs

示例10: TestUTF16String

        public void TestUTF16String()
        {
            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms, new UnicodeEncoding()))
            using (SerializationReader sr = new SerializationReader(ms, new UnicodeEncoding()))
            {
                StringBuilder sb = new StringBuilder();
                for (int i = 0; i < 55296; i++)
                    sb.Append((char)i);
                string res = sb.ToString();
                sw.Write(res);

                sw.Flush();
                ms.Position = 0;

                Assert.AreEqual(res, sr.Read<string>());
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:18,代码来源:StringTests.cs

示例11: TestBytes

        public void TestBytes()
        {
            Random rand = new Random();

            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms))
            using (SerializationReader sr = new SerializationReader(ms))
            {
                byte[] values = new byte[Config.MULTI_TEST_COUNT];
                rand.NextBytes(values);
                for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
                    sw.Write(values[i]);

                sw.Flush();
                ms.Position = 0;

                for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
                    Assert.AreEqual(values[i], sr.Read<byte>());
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:20,代码来源:PrimitiveTests.cs

示例12: TestBasicList

        public void TestBasicList()
        {
            Random rand = new Random();

            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms))
            using (SerializationReader sr = new SerializationReader(ms))
            {
                List<int> list = new List<int>(Config.MULTI_TEST_COUNT);
                for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
                    list.Add(rand.Next(int.MinValue, int.MaxValue));
                sw.Write(list);

                sw.Flush();
                ms.Position = 0;

                List<int> ret = sr.Read<List<int>>();
                for (int i = 0; i < list.Count; i++)
                    Assert.AreEqual(list[i], ret[i]);
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:21,代码来源:ArrayTests.cs

示例13: TestBasicDictionary

        public void TestBasicDictionary()
        {
            Random rand = new Random();

            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms))
            using (SerializationReader sr = new SerializationReader(ms))
            {
                Dictionary<int, float> dict = new Dictionary<int, float>(Config.MULTI_TEST_COUNT);
                for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
                    dict[rand.Next(int.MinValue, int.MaxValue)] = (float)rand.NextDouble();
                sw.Write(dict);

                sw.Flush();
                ms.Position = 0;

                Dictionary<int, float> ret = sr.Read<Dictionary<int, float>>();
                foreach (KeyValuePair<int, float> kvp in dict)
                    Assert.AreEqual(kvp.Value, ret[kvp.Key]);
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:21,代码来源:ArrayTests.cs

示例14: TestBasicArray

        public void TestBasicArray()
        {
            Random rand = new Random();

            using (MemoryStream ms = new MemoryStream())
            using (SerializationWriter sw = new SerializationWriter(ms))
            using (SerializationReader sr = new SerializationReader(ms))
            {
                int[] array = new int[Config.MULTI_TEST_COUNT];
                for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
                    array[i] = rand.Next(int.MinValue, int.MaxValue);
                sw.Write(array);

                sw.Flush();
                ms.Position = 0;

                int[] ret = sr.Read<int[]>();
                for (int i = 0; i < ret.Length; i++)
                    Assert.AreEqual(array[i], ret[i]);
            }
        }
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:21,代码来源:ArrayTests.cs

示例15: Serialize

        public byte[] Serialize()
        {
            SerializationWriter writer = new SerializationWriter();

            writer.WriteObject(ServerName);
            writer.WriteObject(Name);
            if (Type == ObjectTypes.Actor)
                writer.WriteObject((byte)0);
            else
            if (Type == ObjectTypes.Sensor)
                writer.WriteObject((byte)1);
            else
            if (Type == ObjectTypes.Unknown)
                writer.WriteObject((byte)2);

            writer.WriteObject(TypeName);
            writer.WriteObject(Timecode.Ticks);
            writer.WriteObject(XS1ObjectID);
            writer.WriteObject(Value);

            return writer.ToArray();
        }
开发者ID:pereritob,项目名称:hacs,代码行数:22,代码来源:XS1_DataObject.cs


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