本文整理汇总了C#中SerializationWriter类的典型用法代码示例。如果您正苦于以下问题:C# SerializationWriter类的具体用法?C# SerializationWriter怎么用?C# SerializationWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SerializationWriter类属于命名空间,在下文中一共展示了SerializationWriter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: TestBools
public void TestBools()
{
Random rand = new Random();
using (MemoryStream ms = new MemoryStream())
using (SerializationWriter sw = new SerializationWriter(ms))
using (SerializationReader sr = new SerializationReader(ms))
{
bool[] values = new bool[Config.MULTI_TEST_COUNT];
for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
{
values[i] = rand.Next(0, 2) == 1;
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<bool>());
}
}
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:22,代码来源:PrimitiveTests.cs
示例17: Serialize
public void Serialize(SerializationWriter writer, object value)
{
Type type = value.GetType();
if (type == typeof(Pair))
Serialize(writer, (Pair) value);
else if (type == typeof(Triplet))
Serialize(writer, (Triplet) value);
else if (type == typeof(StateBag))
Serialize(writer, (StateBag) value);
else if (type == typeof(Unit))
Serialize(writer, (Unit) value);
else if (type == typeof(Hashtable))
Serialize(writer, (Hashtable) value);
else
{
throw new InvalidOperationException(string.Format("{0} does not support Type: {1}", GetType(), type));
}
}
开发者ID:elementar,项目名称:Suprifattus.Util,代码行数:23,代码来源:WebFastSerializationHelper.cs
示例18: TestDateTimes
public void TestDateTimes()
{
Random rand = new Random();
using (MemoryStream ms = new MemoryStream())
using (SerializationWriter sw = new SerializationWriter(ms))
using (SerializationReader sr = new SerializationReader(ms))
{
DateTime[] values = new DateTime[Config.MULTI_TEST_COUNT];
for (int i = 0; i < Config.MULTI_TEST_COUNT; i++)
{
values[i] = new DateTime(rand.Next(1970, 5623), rand.Next(1, 13), rand.Next(1, 29), rand.Next(0, 24), rand.Next(0, 60), rand.Next(0, 60), DateTimeKind.Utc);
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<DateTime>());
}
}
开发者ID:smoogipooo,项目名称:SerializationLib,代码行数:23,代码来源:PrimitiveTests.cs
示例19: GetObjectData
protected virtual void GetObjectData(SerializationWriter sw)
{
if (IsCompactable) {
// OPT: compact all parts before serialization
Compact();
}
sw.Write(f_TimeStamp);
sw.Write(f_MessageParts);
sw.Write((Int32) f_MessageType);
}
开发者ID:grendello,项目名称:smuxi,代码行数:11,代码来源:MessageModel.cs
示例20: Serialize
public virtual void Serialize(SerializationWriter writer)
{
writer.WritePointer(codelets); // info.AddValue("codelets", codelets)
}
开发者ID:killix,项目名称:Virsona-ChatBot-Tools,代码行数:4,代码来源:Coderack.cs
注:本文中的SerializationWriter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论