• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BinarySerializer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: GetBufferTest

 public void GetBufferTest()
 {
     var binarySerializer = new BinarySerializer();
     var buffer = binarySerializer.GetBuffer(new TestHelpers.Customer(21));
     var customer = binarySerializer.Deserializer(buffer, typeof(Customer));
     Assert.IsInstanceOfType(customer, typeof(Customer));
 }
开发者ID:yonglehou,项目名称:Daytona,代码行数:7,代码来源:BinarySerializerTests.cs


示例2: 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


示例3: GetBuffer_UseGeneric

 public void GetBuffer_UseGeneric()
 {
     var binarySerializer = new BinarySerializer();
     var buffer = binarySerializer.GetBuffer(new TestHelpers.Customer(32));
     var customer = binarySerializer.Deserializer<Customer>(buffer);
     Assert.IsInstanceOfType(customer, typeof(Customer));
 }
开发者ID:yonglehou,项目名称:Daytona,代码行数:7,代码来源:BinarySerializerTests.cs


示例4:

 /// <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


示例5: LoadState

        private void LoadState()
        {
            try
            {
                var ser = new BinarySerializer();
                var stat = ser.Deserialize(StateFileName) as Dictionary<String, Object>;

                if (stat != null)
                {
                    var w = (Int32)stat["Width"];
                    var h = (Int32)stat["Height"];

                    if (w > MinimumSize.Width)
                        Width = w;

                    if (h > MinimumSize.Height)
                        Height = h;

                    var x = (Int32)stat["X"];
                    var y = (Int32)stat["Y"];

                    if (x > 0 && y > 0)
                        Location = new Point(x, y);

                    foreach (var p in GetType().GetProperties())
                    {
                        if (Attribute.IsDefined(p, typeof(StateItemAttribute)))
                            p.SetValue(this, stat[p.Name], null);
                    }
                }
            }
            catch { }
        }
开发者ID:rizwan3d,项目名称:elalang,代码行数:33,代码来源:StateForm.cs


示例6:

 /// <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


示例7: DocumentCategorizerComponent

 public DocumentCategorizerComponent(string modelFileName)
     : base(typeof(DocumentCategorizerComponent))
 {
     mBlockSelector = "TextBlock";
     BinarySerializer reader = new BinarySerializer(modelFileName, FileMode.Open);
     LoadModel(reader);
 }
开发者ID:project-first,项目名称:latinoworkflows,代码行数:7,代码来源:DocumentCategorizerComponent.cs


示例8: Load

 public void Load(BinarySerializer reader)
 {
     TotalHits = reader.ReadLong();
     ActualSize = reader.ReadInt();
     ResultSetXml = reader.ReadString();
     TimeStamp = DateTime.FromOADate(reader.ReadDouble());
 }
开发者ID:project-first,项目名称:latino,代码行数:7,代码来源:CacheRecord.cs


示例9: 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


示例10: Main

        private static void Main(string[] args)
        {
            var file = args[0];

            using (var stream = new FileStream(file, FileMode.Open, FileAccess.Read))
            {
                var serializer = new BinarySerializer();
                serializer.MemberDeserialized += (sender, eventArgs) => Console.WriteLine(eventArgs.MemberName + " : " + eventArgs.Value);

                var iso = serializer.Deserialize<Iso9660.Iso9660>(stream);
                stream.Position = 0;

                var xmlSerializer = new XmlSerializer(typeof (Iso9660.Iso9660));

                var outfilePath = Path.GetDirectoryName(file);
                var outfileName = Path.GetFileNameWithoutExtension(file) + ".xml";
                var outfile = Path.Combine(outfilePath, outfileName);

                using (var xmlStream = new FileStream(outfile, FileMode.Create, FileAccess.Write))
                {
                    xmlSerializer.Serialize(xmlStream, iso);
                }

                Console.ReadKey();
            }
        }
开发者ID:andyvans,项目名称:BinarySerializer,代码行数:26,代码来源:Program.cs


示例11: Save

 // *** ISerializable interface implementation ***
 public void Save(BinarySerializer writer)
 {
     writer.WriteLong(TotalHits);
     writer.WriteInt(ActualSize);
     writer.WriteString(ResultSetXml);
     writer.WriteDouble(TimeStamp.ToOADate());
 }
开发者ID:project-first,项目名称:latino,代码行数:8,代码来源:CacheRecord.cs


示例12: Load

 public void Load(BinarySerializer reader)
 {
     Utils.ThrowException(reader == null ? new ArgumentNullException("reader") : null);
     // the following statements throw serialization-related exceptions
     mLanguage = (Language)reader.ReadInt();
     CreateStemmer();
 }
开发者ID:viidea,项目名称:latino,代码行数:7,代码来源:Stemmer.cs


示例13: SerializeAndReadBack

        public void SerializeAndReadBack()
        {
            var registry = new DependencyFingerprintProtocolRegistry();
            registry.Register<CombinedFingerprintProtocol>();
            registry.Register<SourceSetFingerprintProtocol>();

            var ser = new BinarySerializer(registry);
            var dep = CreateDependencyObject();
            var fp1 = dep.Fingerprint;

            byte[] data;
            using (var ms = new MemoryStream())
            {
                fp1.Save(ser, ms);
                data = ms.ToArray();
            }

            CombinedFingerprint fp2;
            using (var ms = new MemoryStream(data))
            {
                fp2 = new CombinedFingerprint(ser, ms);
            }

            fp1.Should().Be(fp2);
        }
开发者ID:vigoo,项目名称:bari,代码行数:25,代码来源:CombinedDependenciesTest.cs


示例14:

            /// <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


示例15: ApplyInternal

        public override ISerializer ApplyInternal()
        {
            var serializer = new BinarySerializer(_binaryFormatter);

            VerifyErrors(serializer);

            return serializer;
        }
开发者ID:Tauron1990,项目名称:Tauron-Application-Common,代码行数:8,代码来源:BinarySerializerConfiguration.cs


示例16: 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


示例17:

 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


示例18:

 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


示例19:

 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


示例20: Should_throw_exception_if_msg_is_null

        public void Should_throw_exception_if_msg_is_null()
        {
            // Arrange
            var serializer = new BinarySerializer();


            // Action
            var str = serializer.Serialize<Customer>(null);
        }
开发者ID:joefeser,项目名称:Burrow.NET,代码行数:9,代码来源:MethodSerialize.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BinaryTree类代码示例发布时间:2022-05-24
下一篇:
C# BinarySearchTree类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap