コード例 #1
0
ファイル: IDSPlugin_Tests.cs プロジェクト: grofit/Infinity
        public void should_correctly_read_well_structured_encrypted_stream()
        {
            var dummyStream = CreateWellStructuredIDSStream(true);
            var plugin = new IDSPlugin(m_DummyEncryption);

            var expectedIDS = new IDSResource();
            expectedIDS.DefaultValue = 10;
            expectedIDS.Mappings.Add(1, "FirstValue");
            expectedIDS.Mappings.Add(2, "SecondValue");
            expectedIDS.Mappings.Add(3, "ThirdValue");

            var result = plugin.Import(dummyStream);

            Assert.That(result, Is.EqualTo(expectedIDS));
        }
コード例 #2
0
ファイル: IDSPlugin.cs プロジェクト: grofit/Infinity
        public IDSResource Import(Stream stream)
        {
            var byteStream = CreateByteStream(stream);

            if (byteStream is EncryptedByteStream)
            { stream.Seek(2, SeekOrigin.Current); }

            var createdIDS = new IDSResource();
            createdIDS.DefaultValue = ConvertToDefaultValue(byteStream.ReadUntilLineFound());

            var line = byteStream.ReadUntilLineFound();
            while (line.Length > 0)
            {
                if (line[0] == CommentFlag)
                { continue; }

                createdIDS.Mappings.Add(ConvertToKeyValuePair(line));
                line = byteStream.ReadUntilLineFound();
            }

            return createdIDS;
        }