コード例 #1
0
ファイル: ABSaveMap.cs プロジェクト: ABCo-Src/ABSave
        public ABSaveDeserializer GetDeserializer(Stream destStream)
        {
            ABSaveDeserializer deserializer = _deserializerPool.TryRent() ?? new ABSaveDeserializer(this);

            deserializer.Initialize(destStream);
            return(deserializer);
        }
コード例 #2
0
        public void Deserialize_FalseBoolObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("F", typeof(bool), new ABSaveSettings());

            // Assert
            Assert.AreEqual(false, result);
        }
コード例 #3
0
        public void DeserializeBool_TrueObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.DeserializeBool("T", new ABSaveSettings());

            // Assert
            Assert.AreEqual(true, result);
        }
コード例 #4
0
        public void Deserialize_LongObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("36263", typeof(long), new ABSaveSettings());

            // Assert
            Assert.AreEqual((long)36263, result);
        }
コード例 #5
0
        public void Deserialize_DateTimeObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("3616316", typeof(DateTime), new ABSaveSettings());

            // Assert
            Assert.AreEqual(new DateTime(3616316), result);
        }
コード例 #6
0
        public void DeserializeDateTime_DateTimeObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.DeserializeDateTime("15136", new ABSaveSettings());

            // Assert
            Assert.AreEqual(new DateTime(15136), result);
        }
コード例 #7
0
        public void Deserialize_StringObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("abcdefg", typeof(string), new ABSaveSettings());

            // Assert
            Assert.AreEqual("abcdefg", result);
        }
コード例 #8
0
        public void DeserializeNumber_IntObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.DeserializeNumber <int>("15136", new ABSaveSettings());

            // Assert
            Assert.AreEqual(15136, result);
        }
コード例 #9
0
        public void Deserialize_DictionaryObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("\u0006FirstItem,FirstValue,SecondItem,SecondValue", typeof(Dictionary <string, string>), new ABSaveSettings(), out ABSavePrimitiveType typ, out bool manuallyParse);

            // Assert
            Assert.AreEqual(ABSavePrimitiveType.Dictionary, typ);
            Assert.AreEqual(true, manuallyParse);
            Assert.AreEqual(null, result);
        }
コード例 #10
0
        public void Deserialize_ArrayObject_ReturnsCertainObject()
        {
            // Act
            var result = ABSaveDeserializer.Deserialize("\u0004First,Second", typeof(string[]), new ABSaveSettings(), out ABSavePrimitiveType typ, out bool manuallyParse);

            // Assert
            Assert.AreEqual(ABSavePrimitiveType.Array, typ);
            Assert.AreEqual(true, manuallyParse);
            Assert.AreEqual(null, result);
        }
コード例 #11
0
ファイル: TestBase.cs プロジェクト: ABCo-Src/ABSave
        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);
        }
コード例 #12
0
ファイル: ABSaveMap.cs プロジェクト: ABCo-Src/ABSave
 internal void ReleaseDeserializer(ABSaveDeserializer serializer) => _deserializerPool.Release(serializer);