當前位置: 首頁>>代碼示例>>C#>>正文


C# BinarySerializer類代碼示例

本文整理匯總了C#中BinarySerializer的典型用法代碼示例。如果您正苦於以下問題:C# BinarySerializer類的具體用法?C# BinarySerializer怎麽用?C# BinarySerializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BinarySerializer類屬於命名空間,在下文中一共展示了BinarySerializer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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


注:本文中的BinarySerializer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。