Esempio n. 1
0
        public virtual object?Deserialize(Stream serializationStream)
        {
            using SignatureReader? signatureReader = new Internal.SignatureReader(serializationStream);
            Stream?stream    = signatureReader.Stream;
            string?signature = signatureReader.Signature;

            foreach (string signature_key in SignatureReaders.Keys)
            {
                if (signature.IndexOf(signature_key) == 0)
                {
                    object?instance = Readers[SignatureReaders[signature_key]](stream);
                    return(instance);
                }
            }
            throw new System.InvalidOperationException($"unrecognized signature '{signature}'");
        }
Esempio n. 2
0
        public object Read(Stream stream)
        {
            using Internal.SignatureReader? signatureReader = new Internal.SignatureReader(stream);
            Stream?stream2   = signatureReader.Stream;
            string?signature = signatureReader.Signature;

            foreach (string signature_key in Keys)
            {
                if (signature.IndexOf(signature_key) == 0)
                {
                    object?item = this[signature_key](stream2);
                    //stream.Close();
                    return(item);
                }
            }
            throw new UnrecognizedSignatureException($"unrecognized signature '{signature.Substring(0, 24)}'");
        }