Example #1
0
        public static ManagedFormAttribute CreateFromList(SerializedList attrLst)
        {
            String Name = attrLst.Items[3].ToString();
            String Syn  = null;

            if (attrLst.Items[4].Items[1].ToString() == "0")
            {
                Syn = Name;
            }
            else
            {
                Syn = attrLst.Items[4].Items[2].Items[1].ToString();
            }

            bool isBasic = attrLst.Items[10].ToString() == "1";

            var pattern = (SerializedList)attrLst.Items[5];

            ManagedFormAttributeType type = new ManagedFormAttributeType();

            type.TypeDescription = V8TypeDescription.ReadFromList(pattern);

            ManagedFormAttribute attr;

            int childCount = Int32.Parse(attrLst.Items[13].ToString());

            if (childCount > 0)
            {
                int baseIndex = 14;

                ManagedFormAttribute[] children = new ManagedFormAttribute[childCount];

                for (int i = 0; i < childCount; i++)
                {
                    SerializedList innerAttr = (SerializedList)attrLst.Items[baseIndex + i];

                    children[i] = CreateChildFromList(innerAttr);
                }

                attr = new ManagedFormAttribute(Name, Syn, type, children);
            }
            else
            {
                attr = new ManagedFormAttribute(Name, Syn, type);
            }

            attr.IsBasic = isBasic;

            return(attr);
        }
Example #2
0
        private static ManagedFormAttribute CreateChildFromList(SerializedList childAttr)
        {
            String Name = childAttr.Items[3].ToString();
            String Syn  = null;

            if (childAttr.Items[4].Items.Count < 3 || childAttr.Items[4].Items[2].ToString() == "0")
            {
                Syn = Name;
            }
            else
            {
                Syn = childAttr.Items[4].Items[2].Items[1].ToString();
            }

            var pattern = (SerializedList)childAttr.Items[5];

            ManagedFormAttributeType type = new ManagedFormAttributeType();

            type.TypeDescription = V8TypeDescription.ReadFromList(pattern);

            return(new ManagedFormAttribute(Name, Syn, type));
        }
Example #3
0
        public MDAttribute(SerializedList attrDestription)
        {
            m_RawContent = attrDestription;

            var attrObj = (SerializedList)(attrDestription.Items[0].Items[1]);
            var test    = attrObj.Items[0].ToString();

            SerializedList StringsBlock;
            SerializedList Pattern;

            if (test == "2")
            {
                StringsBlock = (SerializedList)attrObj.Items[1];
                Pattern      = (SerializedList)attrObj.Items[2];
            }
            else
            {
                StringsBlock = (SerializedList)(attrObj.Items[1].Items[1]);
                Pattern      = (SerializedList)(attrObj.Items[1].Items[2]);
            }

            ReadStringsBlock(StringsBlock);
            m_typeDef = V8TypeDescription.ReadFromList(Pattern);
        }
Example #4
0
        public static V8TypeDescription ReadFromList(SerializedList pattern)
        {
            if (pattern.Items[0].ToString() != "Pattern")
            {
                throw new ArgumentException("Wrong pattern stream");
            }

            V8Type[]          types = new V8Type[pattern.Items.Count - 1];
            V8NumberQualifier numQ  = null;
            V8StringQualifier strQ  = null;
            V8DateQualifier   dateQ = null;

            for (int i = 1; i < pattern.Items.Count; i++)
            {
                SerializedList item = (SerializedList)pattern.Items[i];

                if (item.Items[0].ToString() == "#")
                {
                    V8Type newType = new V8Type(item.Items[1].ToString(), item.Items[1].ToString()); // пока статичные id разбирать не будем
                    types[i - 1] = newType;
                }
                else
                {
                    String typeToken = item.Items[0].ToString();

                    switch (typeToken)
                    {
                    case "N":
                        types[i - 1] = V8BasicTypes.Number;

                        if (item.Items.Count > 1)
                        {
                            // указан квалификатор
                            numQ = new V8NumberQualifier(Int32.Parse(item.Items[1].ToString()),
                                                         Int32.Parse(item.Items[2].ToString()), item.Items[3].ToString() == "1");
                        }

                        break;

                    case "S":

                        types[i - 1] = V8BasicTypes.String;

                        if (item.Items.Count > 1)
                        {
                            // указан квалификатор
                            strQ = new V8StringQualifier(Int32.Parse(item.Items[1].ToString()),
                                                         (item.Items[2].ToString() == "0") ? V8StringQualifier.AvailableLengthType.Fixed : V8StringQualifier.AvailableLengthType.Variable);
                        }

                        break;

                    case "D":

                        types[i - 1] = V8BasicTypes.Date;

                        if (item.Items.Count > 1)
                        {
                            // указан квалификатор
                            dateQ = new V8DateQualifier((item.Items[1].ToString() == "T") ? V8DateQualifier.DateFractionsType.Time : V8DateQualifier.DateFractionsType.Date);
                        }
                        else
                        {
                            dateQ = new V8DateQualifier(V8DateQualifier.DateFractionsType.DateAndTime);
                        }

                        break;

                    case "B":

                        types[i - 1] = V8BasicTypes.Boolean;
                        break;

                    default:

                        V8Type newType = new V8Type("Unknown", "U");     // пока не знаю про U
                        types[i - 1] = newType;

                        break;
                    }
                }
            }

            V8TypeDescription result = new V8TypeDescription(types, numQ, strQ, dateQ);

            return(result);
        }