Exemple #1
0
        private List <Keyword> ReadKeywords(BinaryReader r)
        {
            var keywords       = new List <Keyword>();
            var keywordEntries = new List <KeywordEntry>();

            ReadMagic(r, CrimsonTags.KEYW);
            var length = r.ReadUInt32();
            var count  = r.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                long   offset     = r.BaseStream.Position;
                var    mask       = r.ReadUInt64();
                var    messageId  = r.ReadUInt32();
                var    nameOffset = r.ReadUInt32();
                string name       = r.ReadCountedStringAt(nameOffset);
                keywordEntries.Add(
                    new KeywordEntry {
                    Mask      = mask,
                    MessageId = messageId,
                    Name      = name,
                });

                var keyword = new Keyword(QName.Parse(name, nsr), Located.Create(mask));
                keyword.Message = ResolveMessage(messageId);
                MarkObject(offset, keyword);
                keywords.Add(keyword);
            }

            foreach (var keyword in keywordEntries)
            {
            }

            return(keywords);
        }
Exemple #2
0
        private List <Level> ReadLevels(BinaryReader r)
        {
            var levels       = new List <Level>();
            var levelEntries = new List <LevelEntry>();

            ReadMagic(r, CrimsonTags.LEVL);
            var length = r.ReadUInt32();
            var count  = r.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                long   offset     = r.BaseStream.Position;
                var    value      = r.ReadUInt32();
                var    messageId  = r.ReadUInt32();
                var    nameOffset = r.ReadUInt32();
                string name       = r.ReadCountedStringAt(nameOffset);
                levelEntries.Add(
                    new LevelEntry {
                    Value     = value,
                    MessageId = messageId,
                    Name      = name,
                });

                var level = new Level(QName.Parse(name, nsr), Located.Create((byte)value));
                level.Message = ResolveMessage(messageId);
                MarkObject(offset, level);
                levels.Add(level);
            }

            foreach (var level in levelEntries)
            {
            }

            return(levels);
        }
Exemple #3
0
    public override TypedQName?ReadJson(JsonReader reader, Type objectType, TypedQName?existingValue, bool hasExistingValue, JsonSerializer serializer)
    {
        if (reader.TokenType != JsonToken.String)
        {
            throw new InvalidOperationException("TypedQName must be encoded as a string");
        }

        var str   = serializer.Deserialize <string>(reader) ?? string.Empty;
        var split = str.Split('/');

        if (split.Length != 2)
        {
            throw new InvalidOperationException("TypedQName must be encoded with two parts.");
        }

        return(new TypedQName(QName.Parse(split[0]), QName.Parse(split[1])));
    }
Exemple #4
0
        public static LocatedRef <QName> GetQName(this XElement elem, string name)
        {
            if (elem == null)
            {
                throw new ArgumentNullException(nameof(elem));
            }
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            XAttribute attrib = elem.Attribute(name);

            if (attrib == null)
            {
                throw CreateMissingAttributeException(elem, name);
            }

            return(Located.Create(
                       QName.Parse(attrib.Value, new XElementNamespaceResolver(elem)),
                       attrib.GetValueLocation()));
        }
Exemple #5
0
        private List <Task> ReadTasks(BinaryReader r)
        {
            var tasks       = new List <Task>();
            var taskEntries = new List <TaskEntry>();

            ReadMagic(r, CrimsonTags.TASK);
            var length = r.ReadUInt32();
            var count  = r.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                long   offset     = r.BaseStream.Position;
                var    value      = r.ReadUInt32();
                var    messageId  = r.ReadUInt32();
                var    guid       = r.ReadGuid();
                var    nameOffset = r.ReadUInt32();
                string name       = r.ReadCountedStringAt(nameOffset);
                taskEntries.Add(
                    new TaskEntry {
                    Value     = value,
                    MessageId = messageId,
                    Guid      = guid,
                    Name      = name,
                });

                var task = new Task(QName.Parse(name, nsr), Located.Create((ushort)value));
                task.Guid    = guid == Guid.Empty ? null : (Guid?)guid;
                task.Message = ResolveMessage(messageId);
                MarkObject(offset, task);
                tasks.Add(task);
            }

            foreach (var task in taskEntries)
            {
            }

            return(tasks);
        }
Exemple #6
0
        private List <Tuple <ushort, Opcode> > ReadOpcodes(BinaryReader r)
        {
            var opcodes       = new List <Tuple <ushort, Opcode> >();
            var opcodeEntries = new List <OpcodeEntry>();

            ReadMagic(r, CrimsonTags.OPCO);
            var length = r.ReadUInt32();
            var count  = r.ReadUInt32();

            for (uint i = 0; i < count; ++i)
            {
                long   offset     = r.BaseStream.Position;
                var    taskId     = r.ReadUInt16();
                var    value      = r.ReadUInt16();
                var    messageId  = r.ReadUInt32();
                var    nameOffset = r.ReadUInt32();
                string name       = r.ReadCountedStringAt(nameOffset);
                opcodeEntries.Add(
                    new OpcodeEntry {
                    TaskId    = taskId,
                    Value     = value,
                    MessageId = messageId,
                    Name      = name,
                });

                var opcode = new Opcode(QName.Parse(name, nsr), Located.Create((byte)value));
                opcode.Message = ResolveMessage(messageId);
                MarkObject(offset, opcode);
                opcodes.Add(Tuple.Create(taskId, opcode));
            }

            foreach (var opcode in opcodeEntries)
            {
            }

            return(opcodes);
        }