Ejemplo n.º 1
0
        public void Serialize_ByteArray()
        {
            var map = ABSaveMap.Get <string>(ABSaveSettings.ForSize);

            byte[] arr = ABSaveConvert.Serialize("A", map);
            Assert.AreNotEqual(0, arr.Length);
        }
Ejemplo n.º 2
0
        public void Setup()
        {
            ABSaveResult = new MemoryStream();
            //WhoaResult = new MemoryStream();
            //NewtonsoftJsonResult = new MemoryStream();
            Utf8JsonResult = new MemoryStream();
            TextJsonResult = new MemoryStream();
            //BinaryFormatterResult = new MemoryStream();
            //XMLResult = new MemoryStream();
            MessagePackResult = new MemoryStream();
            BinaryPackResult  = new MemoryStream();

            Map        = ABSaveMap.Get <JsonResponseModel>(ABSaveSettings.ForSpeed);
            Serializer = Map.GetSerializer(ABSaveResult);

            var str = File.ReadAllText($@"{Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)}\model.txt");

            JsonBytes = Encoding.UTF8.GetBytes(str);
            TestObj   = JsonSerializer.Deserialize <JsonResponseModel>(str);

            // Serialize everyone
            ABSave();
            UTF8Json();
            TextJson();
            MessagePack();
            BinaryPack();
        }
Ejemplo n.º 3
0
        public void Deserialize_ByteArray()
        {
            var map = ABSaveMap.Get <string>(ABSaveSettings.ForSize);

            byte[] arr = ABSaveConvert.Serialize("A", map);

            Assert.AreEqual("A", ABSaveConvert.Deserialize <string>(arr, map));
        }
Ejemplo n.º 4
0
        public void Initialize(ABSaveSettings template, Dictionary <Type, uint> targetVersions = null, bool lazyWriteCompressed = false)
        {
            var settings = template.Customize(b => b
                                              .SetLazyWriteCompressed(lazyWriteCompressed)
                                              .AddConverter <BaseTypeConverter>()
                                              .AddConverter <SubTypeConverter>()
                                              .AddConverter <OtherTypeConverter>()
                                              );

            CurrentMap = ABSaveMap.Get <EmptyClass>(settings);

            Stream       = new MemoryStream();
            Serializer   = CurrentMap.GetSerializer(Stream, targetVersions);
            Deserializer = CurrentMap.GetDeserializer(Stream);
        }