本文整理汇总了C#中BinarySerializer.Serialize方法的典型用法代码示例。如果您正苦于以下问题:C# BinarySerializer.Serialize方法的具体用法?C# BinarySerializer.Serialize怎么用?C# BinarySerializer.Serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BinarySerializer
的用法示例。
在下文中一共展示了BinarySerializer.Serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: foreach
void IDataSerializable.Serialize(BinarySerializer serializer)
{
if (serializer.Mode == SerializerMode.Write)
{
serializer.Writer.Write(Textures.Count);
foreach (var texture in Textures)
{
var name = texture.Key;
var list = texture.Value;
serializer.Serialize(ref name);
serializer.Serialize(ref list);
}
}
else
{
var count = serializer.Reader.ReadInt32();
Textures = new Dictionary<string, List<MaterialTexture>>(count);
for(int i = 0; i < count; i++)
{
string name = null;
List<MaterialTexture> list = null;
serializer.Serialize(ref name);
serializer.Serialize(ref list);
Textures.Add(name, list);
}
}
serializer.Serialize(ref Properties);
}
示例2:
/// <inheritdoc/>
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Name);
serializer.Serialize(ref ShareConstantBuffers);
serializer.Serialize(ref Techniques);
serializer.Serialize(ref Arguments, SerializeFlags.Nullable);
}
示例3:
/// <summary>Reads or writes datas from/to the given binary serializer.</summary>
/// <param name="serializer">The binary serializer.</param>
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref MaterialIndex);
serializer.Serialize(ref IndexBufferRange);
serializer.Serialize(ref VertexBufferRange);
serializer.Serialize(ref Properties);
}
示例4:
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref FilePath);
serializer.Serialize(ref DependencyFilePath);
serializer.SerializeEnum(ref CompilerFlags);
serializer.Serialize(ref Macros, SerializeFlags.Nullable);
serializer.Serialize(ref IncludeDirectoryList, serializer.Serialize, SerializeFlags.Nullable);
}
示例5: Serialize
public void Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Index);
serializer.Serialize(ref ParentBoneIndex);
serializer.Serialize(ref Name, false, SerializeFlags.Nullable);
serializer.Serialize(ref MeshParts);
serializer.Serialize(ref Attributes);
}
示例6:
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Index);
serializer.Serialize(ref ParentIndex);
serializer.Serialize(ref Transform);
serializer.Serialize(ref Name, false, SerializeFlags.Nullable);
serializer.Serialize(ref Children, serializer.Serialize, SerializeFlags.Nullable);
}
示例7:
/// <inheritdoc/>
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Name, SerializeFlags.Nullable);
serializer.Serialize(ref IsSubPass);
serializer.Serialize(ref Attributes);
serializer.Serialize(ref Pipeline);
}
示例8:
void IDataSerializable.Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Character);
serializer.Serialize(ref Subrect);
serializer.Serialize(ref Offset);
serializer.Serialize(ref XAdvance);
serializer.Serialize(ref BitmapIndex);
}
示例9: Serialize
public void Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref FilePath);
serializer.Serialize(ref Index);
serializer.Serialize(ref UVIndex);
serializer.Serialize(ref BlendFactor);
serializer.SerializeEnum(ref Operation);
serializer.SerializeEnum(ref WrapMode);
serializer.SerializeEnum(ref Flags);
}
示例10: Serialize
public void Serialize(BinarySerializer serializer)
{
serializer.Serialize(ref Name, false, SerializeFlags.Nullable);
serializer.Serialize(ref ParentBoneIndex);
serializer.Serialize(ref BoundingSphere);
serializer.Serialize(ref VertexBuffers);
serializer.Serialize(ref IndexBuffers);
serializer.Serialize(ref MeshParts);
serializer.Serialize(ref Properties);
}
示例11: BitmapData
void IDataSerializable.Serialize(BinarySerializer serializer)
{
if (serializer.Mode == SerializerMode.Read)
{
var data = new BitmapData();
serializer.Serialize(ref data);
Data = data;
}
else
{
var data = (BitmapData)Data;
serializer.Serialize(ref data);
}
}
示例12: SerializeTest
public void SerializeTest()
{
BinarySerializer serializer = new BinarySerializer();
MemoryStream stream = serializer.Serialize(new List<string>() { "f", "s" });
Assert.IsNotNull(stream);
}
示例13: SerializableTest
public void SerializableTest()
{
BinarySerializer serializer = new BinarySerializer();
SerializableObject obj1 = new SerializableObject() { Name = "test" };
serializer.Serialize(obj1);
try
{
NonSerializableObject obj2 = new NonSerializableObject() { Name = "test" };
serializer.Serialize(obj2);
}
catch (Exception ex)
{
Assert.IsInstanceOfType(ex, typeof(SerializationException));
}
}
示例14: DeserializeTest
public void DeserializeTest()
{
BinarySerializer serializer = new BinarySerializer();
var data = new List<string>() { "f", "s" };
MemoryStream stream = serializer.Serialize(data);
var obj2 = serializer.Deserializer<List<string>>(stream);
Assert.AreEqual(data[0], obj2[0]);
}
示例15: Publish
public void Publish(string message, string routingKey)
{
var properties = _channel.CreateBasicProperties();
properties.DeliveryMode = Persistent;
var serializer = new BinarySerializer<string>();
var bytes = serializer.Serialize(message);
_channel.BasicPublish(ExchangeName, routingKey, true, false, properties, bytes);
}