protected internal override void ParseQuery(string query)
        {
            string str        = null;
            string tokenValue = null;
            string str3       = null;
            string str4       = null;
            int    num;
            bool   flag  = false;
            bool   flag2 = false;
            string strA  = query.Trim();

            if (string.Compare(strA, 0, tokenReferences, 0, tokenReferences.Length, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"), "references");
            }
            strA = strA.Remove(0, tokenReferences.Length);
            if ((strA.Length == 0) || !char.IsWhiteSpace(strA[0]))
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            strA = strA.TrimStart(null);
            if (string.Compare(strA, 0, tokenOf, 0, tokenOf.Length, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"), "of");
            }
            strA = strA.Remove(0, tokenOf.Length).TrimStart(null);
            if (strA.IndexOf('{') != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            strA = strA.Remove(0, 1).TrimStart(null);
            if (-1 == (num = strA.IndexOf('}')))
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            str  = strA.Substring(0, num).TrimEnd(null);
            strA = strA.Remove(0, num + 1).TrimStart(null);
            if (0 >= strA.Length)
            {
                goto Label_0366;
            }
            if (string.Compare(strA, 0, tokenWhere, 0, tokenWhere.Length, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"), "where");
            }
            strA = strA.Remove(0, tokenWhere.Length);
            if ((strA.Length == 0) || !char.IsWhiteSpace(strA[0]))
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            strA = strA.TrimStart(null);
            bool bTokenFound = false;
            bool flag4       = false;
            bool flag5       = false;
            bool flag6       = false;
            bool flag7       = false;

Label_01D8:
            while ((strA.Length >= tokenResultClass.Length) && (string.Compare(strA, 0, tokenResultClass, 0, tokenResultClass.Length, StringComparison.OrdinalIgnoreCase) == 0))
            {
                ManagementQuery.ParseToken(ref strA, tokenResultClass, "=", ref bTokenFound, ref tokenValue);
            }
            if ((strA.Length >= tokenRole.Length) && (string.Compare(strA, 0, tokenRole, 0, tokenRole.Length, StringComparison.OrdinalIgnoreCase) == 0))
            {
                ManagementQuery.ParseToken(ref strA, tokenRole, "=", ref flag4, ref str3);
                goto Label_01D8;
            }
            if ((strA.Length >= tokenRequiredQualifier.Length) && (string.Compare(strA, 0, tokenRequiredQualifier, 0, tokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase) == 0))
            {
                ManagementQuery.ParseToken(ref strA, tokenRequiredQualifier, "=", ref flag5, ref str4);
                goto Label_01D8;
            }
            if ((strA.Length >= tokenClassDefsOnly.Length) && (string.Compare(strA, 0, tokenClassDefsOnly, 0, tokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase) == 0))
            {
                ManagementQuery.ParseToken(ref strA, tokenClassDefsOnly, ref flag6);
                flag = true;
                goto Label_01D8;
            }
            if ((strA.Length >= tokenSchemaOnly.Length) && (string.Compare(strA, 0, tokenSchemaOnly, 0, tokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase) == 0))
            {
                ManagementQuery.ParseToken(ref strA, tokenSchemaOnly, ref flag7);
                flag2 = true;
                goto Label_01D8;
            }
            if (strA.Length != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            if (flag && flag2)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
Label_0366:
            this.sourceObject          = str;
            this.relationshipClass     = tokenValue;
            this.thisRole              = str3;
            this.relationshipQualifier = str4;
            this.classDefinitionsOnly  = flag;
            this.isSchemaQuery         = flag2;
        }
Пример #2
0
        protected internal override void ParseQuery(string query)
        {
            string str;
            string str1;

            this.eventClassName      = null;
            this.withinInterval      = TimeSpan.Zero;
            this.condition           = null;
            this.groupWithinInterval = TimeSpan.Zero;
            if (this.groupByPropertyList != null)
            {
                this.groupByPropertyList.Clear();
            }
            this.havingCondition = null;
            string str2 = query.Trim();
            bool   flag = false;
            string str3 = ManagementQuery.tokenSelect;

            if (str2.Length < str3.Length || string.Compare(str2, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) != 0)
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
            }
            else
            {
                str2 = str2.Remove(0, str3.Length).TrimStart(null);
                if (str2.StartsWith("*", StringComparison.Ordinal))
                {
                    str2 = str2.Remove(0, 1).TrimStart(null);
                    str3 = "from ";
                    if (str2.Length < str3.Length || string.Compare(str2, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) != 0)
                    {
                        throw new ArgumentException(RC.GetString("INVALID_QUERY"), "from");
                    }
                    else
                    {
                        ManagementQuery.ParseToken(ref str2, str3, null, ref flag, ref this.eventClassName);
                        str3 = "within ";
                        if (str2.Length >= str3.Length && string.Compare(str2, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            string str4 = null;
                            flag = false;
                            ManagementQuery.ParseToken(ref str2, str3, null, ref flag, ref str4);
                            this.withinInterval = TimeSpan.FromSeconds(((IConvertible)str4).ToDouble(null));
                        }
                        str3 = "group within ";
                        if (str2.Length >= str3.Length)
                        {
                            int num  = str2.ToLower(CultureInfo.InvariantCulture).IndexOf(str3, StringComparison.Ordinal);
                            int num1 = num;
                            if (num == -1)
                            {
                                str  = str2.Trim();
                                str3 = "where ";
                                if (str.Length >= str3.Length && string.Compare(str, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                                {
                                    this.condition = str.Substring(str3.Length);
                                }
                                return;
                            }
                            str  = str2.Substring(0, num1).Trim();
                            str2 = str2.Remove(0, num1);
                            string str5 = null;
                            flag = false;
                            ManagementQuery.ParseToken(ref str2, str3, null, ref flag, ref str5);
                            this.groupWithinInterval = TimeSpan.FromSeconds(((IConvertible)str5).ToDouble(null));
                            str3 = "by ";
                            if (str2.Length >= str3.Length && string.Compare(str2, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                str2 = str2.Remove(0, str3.Length);
                                if (this.groupByPropertyList == null)
                                {
                                    this.groupByPropertyList = new StringCollection();
                                }
                                else
                                {
                                    this.groupByPropertyList.Clear();
                                }
                                while (true)
                                {
                                    int num2 = str2.IndexOf(',');
                                    num1 = num2;
                                    if (num2 <= 0)
                                    {
                                        break;
                                    }
                                    str1 = str2.Substring(0, num1);
                                    str2 = str2.Remove(0, num1 + 1).TrimStart(null);
                                    str1 = str1.Trim();
                                    if (str1.Length > 0)
                                    {
                                        this.groupByPropertyList.Add(str1);
                                    }
                                }
                                int num3 = str2.IndexOf(' ');
                                num1 = num3;
                                if (num3 <= 0)
                                {
                                    this.groupByPropertyList.Add(str2);
                                    return;
                                }
                                else
                                {
                                    str1 = str2.Substring(0, num1);
                                    str2 = str2.Remove(0, num1).TrimStart(null);
                                    this.groupByPropertyList.Add(str1);
                                }
                            }
                            str3 = "having ";
                            if (str2.Length >= str3.Length && string.Compare(str2, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                            {
                                str2 = str2.Remove(0, str3.Length);
                                if (str2.Length != 0)
                                {
                                    this.havingCondition = str2;
                                    str3 = "where ";
                                    if (str.Length >= str3.Length && string.Compare(str, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        this.condition = str.Substring(str3.Length);
                                    }
                                    return;
                                }
                                else
                                {
                                    throw new ArgumentException(RC.GetString("INVALID_QUERY"), "having");
                                }
                            }
                            else
                            {
                                str3 = "where ";
                                if (str.Length >= str3.Length && string.Compare(str, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                                {
                                    this.condition = str.Substring(str3.Length);
                                }
                                return;
                            }
                        }
                        str  = str2.Trim();
                        str3 = "where ";
                        if (str.Length >= str3.Length && string.Compare(str, 0, str3, 0, str3.Length, StringComparison.OrdinalIgnoreCase) == 0)
                        {
                            this.condition = str.Substring(str3.Length);
                        }
                        return;
                    }
                }
                else
                {
                    throw new ArgumentException(RC.GetString("INVALID_QUERY"), "*");
                }
            }
        }
Пример #3
0
        protected internal override void ParseQuery(string query)
        {
            string str   = null;
            string str1  = null;
            string str2  = null;
            bool   flag  = false;
            bool   flag1 = false;
            string str3  = query.Trim();

            if (string.Compare(str3, 0, RelationshipQuery.tokenReferences, 0, RelationshipQuery.tokenReferences.Length, StringComparison.OrdinalIgnoreCase) == 0)
            {
                str3 = str3.Remove(0, RelationshipQuery.tokenReferences.Length);
                if (str3.Length == 0 || !char.IsWhiteSpace(str3[0]))
                {
                    throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                }
                else
                {
                    str3 = str3.TrimStart(null);
                    if (string.Compare(str3, 0, RelationshipQuery.tokenOf, 0, RelationshipQuery.tokenOf.Length, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        str3 = str3.Remove(0, RelationshipQuery.tokenOf.Length).TrimStart(null);
                        if (str3.IndexOf('{') == 0)
                        {
                            str3 = str3.Remove(0, 1).TrimStart(null);
                            int num  = str3.IndexOf('}');
                            int num1 = num;
                            if (-1 != num)
                            {
                                string str4 = str3.Substring(0, num1).TrimEnd(null);
                                str3 = str3.Remove(0, num1 + 1).TrimStart(null);
                                if (0 < str3.Length)
                                {
                                    if (string.Compare(str3, 0, RelationshipQuery.tokenWhere, 0, RelationshipQuery.tokenWhere.Length, StringComparison.OrdinalIgnoreCase) == 0)
                                    {
                                        str3 = str3.Remove(0, RelationshipQuery.tokenWhere.Length);
                                        if (str3.Length == 0 || !char.IsWhiteSpace(str3[0]))
                                        {
                                            throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                                        }
                                        else
                                        {
                                            str3 = str3.TrimStart(null);
                                            bool flag2 = false;
                                            bool flag3 = false;
                                            bool flag4 = false;
                                            bool flag5 = false;
                                            bool flag6 = false;
                                            while (true)
                                            {
                                                if (str3.Length < RelationshipQuery.tokenResultClass.Length || string.Compare(str3, 0, RelationshipQuery.tokenResultClass, 0, RelationshipQuery.tokenResultClass.Length, StringComparison.OrdinalIgnoreCase) != 0)
                                                {
                                                    if (str3.Length < RelationshipQuery.tokenRole.Length || string.Compare(str3, 0, RelationshipQuery.tokenRole, 0, RelationshipQuery.tokenRole.Length, StringComparison.OrdinalIgnoreCase) != 0)
                                                    {
                                                        if (str3.Length < RelationshipQuery.tokenRequiredQualifier.Length || string.Compare(str3, 0, RelationshipQuery.tokenRequiredQualifier, 0, RelationshipQuery.tokenRequiredQualifier.Length, StringComparison.OrdinalIgnoreCase) != 0)
                                                        {
                                                            if (str3.Length < RelationshipQuery.tokenClassDefsOnly.Length || string.Compare(str3, 0, RelationshipQuery.tokenClassDefsOnly, 0, RelationshipQuery.tokenClassDefsOnly.Length, StringComparison.OrdinalIgnoreCase) != 0)
                                                            {
                                                                if (str3.Length < RelationshipQuery.tokenSchemaOnly.Length || string.Compare(str3, 0, RelationshipQuery.tokenSchemaOnly, 0, RelationshipQuery.tokenSchemaOnly.Length, StringComparison.OrdinalIgnoreCase) != 0)
                                                                {
                                                                    break;
                                                                }
                                                                ManagementQuery.ParseToken(ref str3, RelationshipQuery.tokenSchemaOnly, ref flag6);
                                                                flag1 = true;
                                                            }
                                                            else
                                                            {
                                                                ManagementQuery.ParseToken(ref str3, RelationshipQuery.tokenClassDefsOnly, ref flag5);
                                                                flag = true;
                                                            }
                                                        }
                                                        else
                                                        {
                                                            ManagementQuery.ParseToken(ref str3, RelationshipQuery.tokenRequiredQualifier, "=", ref flag4, ref str2);
                                                        }
                                                    }
                                                    else
                                                    {
                                                        ManagementQuery.ParseToken(ref str3, RelationshipQuery.tokenRole, "=", ref flag3, ref str1);
                                                    }
                                                }
                                                else
                                                {
                                                    ManagementQuery.ParseToken(ref str3, RelationshipQuery.tokenResultClass, "=", ref flag2, ref str);
                                                }
                                            }
                                            if (str3.Length == 0)
                                            {
                                                if (flag && flag1)
                                                {
                                                    throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                                                }
                                            }
                                            else
                                            {
                                                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                                            }
                                        }
                                    }
                                    else
                                    {
                                        throw new ArgumentException(RC.GetString("INVALID_QUERY"), "where");
                                    }
                                }
                                this.sourceObject          = str4;
                                this.relationshipClass     = str;
                                this.thisRole              = str1;
                                this.relationshipQualifier = str2;
                                this.classDefinitionsOnly  = flag;
                                this.isSchemaQuery         = flag1;
                                return;
                            }
                            else
                            {
                                throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                            }
                        }
                        else
                        {
                            throw new ArgumentException(RC.GetString("INVALID_QUERY"));
                        }
                    }
                    else
                    {
                        throw new ArgumentException(RC.GetString("INVALID_QUERY"), "of");
                    }
                }
            }
            else
            {
                throw new ArgumentException(RC.GetString("INVALID_QUERY"), "references");
            }
        }