Пример #1
0
            private Market(BinaryReader reader, int version, string language) : base(reader, version, language)
            {
                Func <Meta.EnumType> loader = null;
                Func <Meta.Message>  func2  = null;
                Func <Meta.Message>  func3  = null;

                this.Language     = language;
                this.enumerations = new Meta.EnumTypes();
                if (loader == null)
                {
                    loader = () => new Meta.EnumType(reader, version, language);
                }
                Meta.LoadItems <Meta.EnumType>(reader, this.enumerations, loader);
                this.tables = new Meta.Messages();
                if (func2 == null)
                {
                    func2 = () => new Meta.Message(reader, version, language, true, this.enumerations);
                }
                Meta.LoadItems <Meta.Message>(reader, this.tables, func2);
                this.transactions = new Meta.Messages();
                if (func3 == null)
                {
                    func3 = () => new Meta.Message(reader, version, language, false, this.enumerations);
                }


                Meta.LoadItems <Meta.Message>(reader, /*this.tables*/ this.transactions, func3);
            }
Пример #2
0
 internal Message(BinaryReader reader, int version, string language, bool table, Meta.EnumTypes enumerations) : base(reader, version, language)
 {
     this.maxEssentialIndex = -1;
     this.system            = (Meta.PureVersion(version) >= 2) ? reader.ReadInt32() : 0;
     this.flags             = table ? reader.ReadInt32() : 0;
     this.input             = new Meta.Fields(this, reader, version, language, true, enumerations);
     this.reply             = table ? new Meta.Fields(this, reader, version, language, false, enumerations) : new Meta.Fields();
     if (!WellKnownTables.TryGetValue(base.Name, out this.type))
     {
         this.type = Meta.TableType.None;
     }
 }
Пример #3
0
            internal Fields(Meta.Message owner, BinaryReader reader, int version, string language, bool input, Meta.EnumTypes enumerations)
            {
                Func <Meta.Field> loader = null;

                this.keys          = new List <Meta.Field>();
                this.varBlockFirst = -1;
                if (loader == null)
                {
                    loader = () => new Meta.Field(reader, version, language, input, enumerations);
                }
                Meta.LoadItems <Meta.Field>(reader, this, loader);
                for (int i = 0; i < base.Count; i++)
                {
                    Meta.Field item = base[i];
                    item.offset = this.size;
                    this.size  += item.Size;
                    item.isKey  = owner.CanHaveKeys && ((item.flags & 1) != 0);
                    if (item.isKey)
                    {
                        this.keys.Add(item);
                        if (!input)
                        {
                            owner.maxEssentialIndex = i;
                        }
                    }
                    if ((item.flags & 8) != 0)
                    {
                        if (this.varBlockCount == 0)
                        {
                            this.varBlockFirst = i;
                            this.varBlockCount++;
                        }
                        else
                        {
                            this.varBlockCount = (1 + i) - this.varBlockFirst;
                        }
                    }
                    if (item.IsSecCode)
                    {
                        this.fldSecCode = item;
                        if (!input)
                        {
                            owner.maxEssentialIndex = i;
                        }
                        for (int j = i - 1; j >= 0; j--)
                        {
                            if (BoardFieldNames.Contains(base[j].Name))
                            {
                                this.fldSecBoard        = base[j];
                                this.fldSecBoard.flags |= 0x200;
                                break;
                            }
                        }
                    }
                    if (MarketFieldNames.Contains(item.Name))
                    {
                        item.flags      |= 0x400;
                        this.fldMarketID = item;
                    }
                    if (ScaleFieldNames.Contains(item.Name))
                    {
                        item.flags      |= 0x100;
                        this.fldDecimals = item;
                        if (!input)
                        {
                            owner.maxEssentialIndex = i;
                        }
                    }
                }
                if (this.fldDecimals == null)
                {
                    for (int k = 0; k < base.Count; k++)
                    {
                        Meta.Field field2 = base[k];
                        if ((field2.Type == Meta.FieldType.Float) && (field2.Decimals < 0))
                        {
                            owner.flags |= 0x400;
                        }
                    }
                }
            }
Пример #4
0
            internal Field(BinaryReader reader, int version, string language, bool input, Meta.EnumTypes enumerations) : base(reader, version, language)
            {
                string str;

                this.size = reader.ReadInt32();
                this.type = (Meta.FieldType)Enum.ToObject(typeof(Meta.FieldType), reader.ReadInt32());
                if (Meta.PureVersion(version) >= 2)
                {
                    this.decimals = reader.ReadInt32();
                }
                this.flags = reader.ReadInt32();
                if (Meta.PureVersion(version) < 2)
                {
                    switch (this.type)
                    {
                    case Meta.FieldType.Fixed:
                        this.decimals = 2;
                        switch ((this.flags & 0x30))
                        {
                        case 0x10:
                            this.decimals = 1;
                            goto Label_00BC;

                        case 0x20:
                            this.decimals = 3;
                            goto Label_00BC;

                        case 0x30:
                            this.decimals = 4;
                            goto Label_00BC;
                        }
                        break;

                    case Meta.FieldType.Float:
                        this.decimals = -1;
                        break;
                    }
                }
Label_00BC:
                str = reader.ReadString();
                if (str.Length > 0)
                {
                    if (!enumerations.Find(str, out this.enumeration))
                    {
                        throw new IOException("Invalid enumeration " + str);
                    }
                }
                else
                {
                    this.enumeration = null;
                }
                this.defaults = input ? reader.ReadString() : string.Empty;
            }