コード例 #1
0
        public Element ReadNextElement()
        {
            ulong position    = (ulong)stream.Position;
            var   elementType = getNextEbmlCodeAsBytes();

            if (elementType == null)
            {
                // Failed to read type id.
                return(null);
            }

            Element elem = ProtoTypeManager.GetInstance(elementType);

            if (elem == null)
            {
                return(null);
            }
            Utility.LogTrace($"Read element {elem.TypeInfo.Name}");

            // Read the size.
            ulong elementSize = ReadEbmlCode(stream);

            if (elementSize == 0)
            {
                Utility.LogError($"Invalid element size for {elem.TypeInfo.Name}");
            }

            ulong end = (ulong)stream.Position;

            // Set it's size
            elem.Size       = elementSize;
            elem.HeaderSize = end - position;

            return(elem);
        }
コード例 #2
0
        public ProtoType(string name, byte[] type, int level)
        {
            Level = level;
            Name  = name;
            Type  = new MemoryStream(type);
            ulong codename = Utility.ParseEbmlCode(Type);

            ProtoTypeManager.AddDictionaryElement(codename, this);
            Utility.LogTrace($"Associating {Name} with {codename}");
        }