Beispiel #1
0
        public static bool LocateElement(this EbmlReader reader, ElementDescriptor descriptor)
        {
            while (reader.ReadNext())
            {
                var identifier = reader.ElementId;

                if (identifier == descriptor.Identifier)
                {
                    return true;
                }
            }
            return false;
        }
Beispiel #2
0
        private Action<EbmlReader> MakeElementDumper(ElementDescriptor element)
        {
            Func<EbmlReader,string> dump = null;
            switch (element.Type)
            {
                case ElementType.AsciiString:
                    dump = reader => reader.ReadAscii();
                    break;
                case ElementType.Binary:
                    dump = _ => "binary data";
                    break;
                case ElementType.Date:
                    dump = r => r.ReadDate().ToString();
                    break;
                case ElementType.Float:
                    dump = r => r.ReadFloat().ToString();
                    break;
                case ElementType.SignedInteger:
                    dump = r => r.ReadInt().ToString();
                    break;
                case ElementType.UnsignedInteger:
                    dump = r => r.ReadUInt().ToString();
                    break;
                case ElementType.Utf8String:
                    dump = r => r.ReadUtf();
                    break;
                default:
                    dump = _ => string.Format("unknown (id:{0})", element.Type.ToString());
                    break;
            }

            return reader =>
                {
                    if (reader.ElementId == element.Identifier)
                    {
                        Console.WriteLine("{0}: {1}", element.Name, dump(reader));
                    }
                };
        }