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


C# BinarySerializer.Serialize方法代码示例

本文整理汇总了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);
            }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:29,代码来源:ModelData.Material.cs

示例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);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:8,代码来源:EffectData.Effect.cs

示例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);
 }
开发者ID:GrafSeismo,项目名称:SharpDX,代码行数:9,代码来源:ModelData.MeshPart.cs

示例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);
 }
开发者ID:GrafSeismo,项目名称:SharpDX,代码行数:8,代码来源:EffectData.CompilerArguments.cs

示例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);
 }
开发者ID:Nezz,项目名称:SharpDX,代码行数:8,代码来源:ModelData.Mesh.cs

示例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);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:8,代码来源:ModelData.Bone.cs

示例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);
            }
开发者ID:Nezz,项目名称:SharpDX,代码行数:9,代码来源:EffectData.Pass.cs

示例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);
 }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:8,代码来源:SpriteFontData.Glyph.cs

示例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);
 }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:10,代码来源:ModelData.MaterialTexture.cs

示例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);
 }
开发者ID:numo16,项目名称:SharpDX,代码行数:10,代码来源:ModelData.Mesh.cs

示例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);
     }
 }
开发者ID:QuantumDeveloper,项目名称:SharpDX,代码行数:14,代码来源:SpriteFontData.Bitmap.cs

示例12: SerializeTest

        public void SerializeTest()
        {
            BinarySerializer serializer = new BinarySerializer();
            MemoryStream stream = serializer.Serialize(new List<string>() { "f", "s" });

            Assert.IsNotNull(stream);
        }
开发者ID:xjpstar,项目名称:simlelivesite,代码行数:7,代码来源:BinarySerializerTest.cs

示例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));
            }
        }
开发者ID:xjpstar,项目名称:simlelivesite,代码行数:17,代码来源:BinarySerializerTest.cs

示例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]);
        }
开发者ID:xjpstar,项目名称:simlelivesite,代码行数:9,代码来源:BinarySerializerTest.cs

示例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);
        }
开发者ID:toddmeinershagen,项目名称:Demo.RabbitMQ,代码行数:9,代码来源:Publisher.cs


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