public ObjectPathRegex(string objectPath) { //WMI infrastructure will double all backslashes. We need to get back to the originals objectPath = objectPath.Replace("\\\\", "\\"); Match match = nsRegEx.Match(objectPath); if (match.Success) { objectPath = match.Groups["path"].Value; } match = classRegEx.Match(objectPath); this.className = match.Groups["className"].Value; string keyValues = match.Groups["keys"].Value; match = keysRegEx.Match(keyValues); if (!match.Success) { WbemException.Throw(WbemNative.WbemStatus.WBEM_E_INVALID_OBJECT_PATH); } while (match.Success) { if (!String.IsNullOrEmpty(match.Groups["ival"].Value)) { this.keys.Add(match.Groups["key"].Value, Int32.Parse(match.Groups["ival"].Value, CultureInfo.CurrentCulture)); } else { this.keys.Add(match.Groups["key"].Value, match.Groups["sval"].Value); } match = match.NextMatch(); } }
public ObjectPathRegex(string objectPath) { objectPath = objectPath.Replace(@"\\", @"\"); Match match = nsRegEx.Match(objectPath); if (match.Success) { objectPath = match.Groups["path"].Value; } match = classRegEx.Match(objectPath); this.className = match.Groups["className"].Value; string input = match.Groups["keys"].Value; match = keysRegEx.Match(input); if (!match.Success) { WbemException.Throw(WbemNative.WbemStatus.WBEM_E_INVALID_OBJECT_PATH); } while (match.Success) { if (!string.IsNullOrEmpty(match.Groups["ival"].Value)) { this.keys.Add(match.Groups["key"].Value, int.Parse(match.Groups["ival"].Value, CultureInfo.CurrentCulture)); } else { this.keys.Add(match.Groups["key"].Value, match.Groups["sval"].Value); } match = match.NextMatch(); } }
internal QueryRegex(string query) { Match match = regEx.Match(query); if (!match.Success) { WbemException.Throw(WbemNative.WbemStatus.WBEM_E_INVALID_QUERY); } this.className = match.Groups["className"].Value; }