Пример #1
0
        /// <summary>
        /// <para>
        /// Throw not found property error
        /// </para>
        /// </summary>
        internal void ThrowInvalidProperty(
            IEnumerable <string> propertiesList,
            string className,
            string parameterName,
            string operationName,
            IDictionary actualValue)
        {
            StringBuilder propList = new StringBuilder();

            foreach (string property in propertiesList)
            {
                if (propList.Length > 0)
                {
                    propList.Append(",");
                }

                propList.Append(property);
            }

            string message = string.Format(CultureInfo.CurrentUICulture, Strings.CouldNotFindPropertyFromGivenClass,
                                           className, propList);
            PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
                parameterName, actualValue, message);

            ThrowTerminatingError(exception, operationName);
        }
Пример #2
0
        internal void ThrowInvalidAuthenticationTypeError(string operationName, string parameterName, PasswordAuthenticationMechanism authentication)
        {
            object[] objArray = new object[5];
            objArray[0] = authentication;
            objArray[1] = ImpersonatedAuthenticationMechanism.None;
            objArray[2] = ImpersonatedAuthenticationMechanism.Negotiate;
            objArray[3] = ImpersonatedAuthenticationMechanism.Kerberos;
            objArray[4] = ImpersonatedAuthenticationMechanism.NtlmDomain;
            string str = string.Format(CultureInfo.CurrentUICulture, Strings.InvalidAuthenticationTypeWithNullCredential, objArray);
            PSArgumentOutOfRangeException pSArgumentOutOfRangeException = new PSArgumentOutOfRangeException(parameterName, (object)authentication, str);

            this.ThrowTerminatingError(pSArgumentOutOfRangeException, operationName);
        }
Пример #3
0
        /// <summary>
        /// <para>
        /// Throw invalid AuthenticationType
        /// </para>
        /// </summary>
        /// <param name="operationName"></param>
        /// <param name="parameterName"></param>
        /// <param name="authentication"></param>
        internal void ThrowInvalidAuthenticationTypeError(
            string operationName,
            string parameterName,
            PasswordAuthenticationMechanism authentication)
        {
            string message = String.Format(CultureInfo.CurrentUICulture, Strings.InvalidAuthenticationTypeWithNullCredential,
                                           authentication,
                                           ImpersonatedAuthenticationMechanism.None,
                                           ImpersonatedAuthenticationMechanism.Negotiate,
                                           ImpersonatedAuthenticationMechanism.Kerberos,
                                           ImpersonatedAuthenticationMechanism.NtlmDomain);
            PSArgumentOutOfRangeException exception = new PSArgumentOutOfRangeException(
                parameterName, authentication, message);

            ThrowTerminatingError(exception, operationName);
        }
Пример #4
0
 protected override void ProcessRecord()
 {
     string[] name = this.Name;
     for (int i = 0; i < (int)name.Length; i++)
     {
         string str = name[i];
         try
         {
             List <PSDriveInfo> matchingDrives = base.GetMatchingDrives(str, this.PSProvider, this.Scope);
             if (matchingDrives.Count <= 0)
             {
                 if (!WildcardPattern.ContainsWildcardCharacters(str))
                 {
                     DriveNotFoundException driveNotFoundException = new DriveNotFoundException(str, "DriveNotFound", SessionStateStrings.DriveNotFound);
                     base.WriteError(new ErrorRecord(driveNotFoundException, "GetDriveNoMatchingDrive", ErrorCategory.ObjectNotFound, str));
                 }
             }
             else
             {
                 base.WriteObject(matchingDrives, true);
             }
         }
         catch (DriveNotFoundException driveNotFoundException2)
         {
             DriveNotFoundException driveNotFoundException1 = driveNotFoundException2;
             ErrorRecord            errorRecord             = new ErrorRecord(driveNotFoundException1, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, str);
             base.WriteError(errorRecord);
         }
         catch (ProviderNotFoundException providerNotFoundException1)
         {
             ProviderNotFoundException providerNotFoundException = providerNotFoundException1;
             ErrorRecord errorRecord1 = new ErrorRecord(providerNotFoundException, "GetLocationNoMatchingDrive", ErrorCategory.ObjectNotFound, this.PSProvider);
             base.WriteError(errorRecord1);
         }
         catch (PSArgumentOutOfRangeException pSArgumentOutOfRangeException1)
         {
             PSArgumentOutOfRangeException pSArgumentOutOfRangeException = pSArgumentOutOfRangeException1;
             base.WriteError(new ErrorRecord(pSArgumentOutOfRangeException.ErrorRecord, pSArgumentOutOfRangeException));
         }
         catch (PSArgumentException pSArgumentException1)
         {
             PSArgumentException pSArgumentException = pSArgumentException1;
             base.WriteError(new ErrorRecord(pSArgumentException.ErrorRecord, pSArgumentException));
         }
     }
 }
Пример #5
0
        internal void ThrowInvalidProperty(IEnumerable <string> propertiesList, string className, string parameterName, string operationName, IDictionary actualValue)
        {
            StringBuilder stringBuilder = new StringBuilder();

            foreach (string str in propertiesList)
            {
                if (stringBuilder.Length > 0)
                {
                    stringBuilder.Append(",");
                }
                stringBuilder.Append(str);
            }
            object[] objArray = new object[2];
            objArray[0] = className;
            objArray[1] = stringBuilder;
            string str1 = string.Format(CultureInfo.CurrentUICulture, Strings.CouldNotFindPropertyFromGivenClass, objArray);
            PSArgumentOutOfRangeException pSArgumentOutOfRangeException = new PSArgumentOutOfRangeException(parameterName, actualValue, str1);

            this.ThrowTerminatingError(pSArgumentOutOfRangeException, operationName);
        }