예제 #1
0
        internal PSArgumentOutOfRangeException NewArgumentOutOfRangeException(
            string paramName,
            object actualValue,
            string baseName,
            string resourceId,
            params object[] args)
        {
            if (string.IsNullOrEmpty(paramName))
            {
                throw this.NewArgumentNullException(nameof(paramName));
            }
            if (string.IsNullOrEmpty(baseName))
            {
                throw this.NewArgumentNullException(nameof(baseName));
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw this.NewArgumentNullException(nameof(resourceId));
            }
            string message = ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args);
            PSArgumentOutOfRangeException ofRangeException = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            this.TraceException((Exception)ofRangeException);
            return(ofRangeException);
        }
예제 #2
0
        internal PSArgumentOutOfRangeException NewArgumentOutOfRangeException(
            string paramName,
            object actualValue)
        {
            string message = !string.IsNullOrEmpty(paramName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ArgumentOutOfRange", (object)paramName) : throw new ArgumentNullException(nameof(paramName));
            PSArgumentOutOfRangeException ofRangeException = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            this.TraceException((Exception)ofRangeException);
            return(ofRangeException);
        }
예제 #3
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant uses the default
        /// ArgumentOutOfRangeException template text. This is not allowed to call
        /// other Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was out of range
        /// </param>
        /// <param name="actualValue">
        /// The value of the argument causing the exception
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(string paramName, object actualValue)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw new ArgumentNullException("paramName");
            }
            string message = StringUtil.Format(AutomationExceptions.ArgumentOutOfRange, paramName);
            var    e       = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            return(e);
        }
예제 #4
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant allows the caller to
        /// specify alternate template text, but only in assembly S.M.A.Core.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was invalid
        /// </param>
        /// <param name="actualValue">
        /// The value of the argument causing the exception
        /// </param>
        /// <param name="resourceString">
        /// The template string for this error
        /// </param>
        /// <param name="args">
        /// Objects corresponding to {0}, {1}, etc. in the resource string
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(
            string paramName, object actualValue, string resourceString, params object[] args)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw NewArgumentNullException("paramName");
            }
            if (String.IsNullOrEmpty(resourceString))
            {
                throw NewArgumentNullException("resourceString");
            }

            string message = StringUtil.Format(resourceString, args);
            var    e       = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            return(e);
        }
예제 #5
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant allows the caller to
        /// specify alternate template text, but only in assembly S.M.A.Core.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was invalid
        /// </param>
        /// <param name="actualValue">
        /// The value of the argument causing the exception
        /// </param>
        /// <param name="resourceString">
        /// The template string for this error
        /// </param>
        /// <param name="args">
        /// Objects corresponding to {0}, {1}, etc. in the resource string
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(
            string paramName, object actualValue, string resourceString, params object[] args)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw NewArgumentNullException("paramName");
            }
            if (String.IsNullOrEmpty(resourceString))
            {
                throw NewArgumentNullException("resourceString");
            }

            string message = StringUtil.Format(resourceString, args);
            var e = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            return e;
        }
예제 #6
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant uses the default
        /// ArgumentOutOfRangeException template text. This is not allowed to call
        /// other Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="paramName">
        /// The name of the parameter whose argument value was out of range
        /// </param>
        /// <param name="actualValue">
        /// The value of the argument causing the exception
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(string paramName, object actualValue)
        {
            if (String.IsNullOrEmpty(paramName))
            {
                throw new ArgumentNullException("paramName");
            }
            string message = StringUtil.Format(AutomationExceptions.ArgumentOutOfRange, paramName);
            var e = new PSArgumentOutOfRangeException(paramName, actualValue, message);

            return e;
        }
예제 #7
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);
 }
예제 #8
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);
 }
예제 #9
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);
		}
예제 #10
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);
		}