Exemple #1
0
        public V8TypeDescription(V8Type[] types, V8NumberQualifier numberQualifier = null, V8StringQualifier stringQualifier = null, V8DateQualifier dateQualifier = null)
        {
            m_types = new V8Type[types.Length];

            types.CopyTo(m_types, 0);
            NumberQualifier = numberQualifier;
            StringQualifier = stringQualifier;
            DateQualifier   = dateQualifier;
        }
Exemple #2
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);
        }