Exemple #1
0
        private string GetObjectName(string[] s, ManagementObjectScope.Type scopeType, string scope)
        {
            int index = (int)(scopeType + 1) * 2;

            if (s.Length >= index + 1 && !s[index - 1].Equals(ManagementObjectScope.ObjectSegmentNames[(int)scopeType], StringComparison.OrdinalIgnoreCase))
            {
                throw new ArgumentException("Invalid " + ManagementObjectScope.ObjectNames[(int)scopeType] + " scope format in RdMgmtObjectScope '" + scope + "'");
            }
            return(s.Length < index + 1 ? (string)null : s[index]);
        }
Exemple #2
0
        public static string GetObjectName(string scope, ManagementObjectScope.Type scopeType)
        {
            if (string.IsNullOrWhiteSpace(scope))
            {
                return((string)null);
            }
            string[] strArray = scope.Split('/');
            if (strArray.Length != 0 && !string.IsNullOrWhiteSpace(strArray[0]))
            {
                return((string)null);
            }
            int index = (int)(scopeType + 1);

            return(strArray.Length < index + 1 || string.IsNullOrWhiteSpace(strArray[index]) ? (string)null : strArray[index]);
        }