예제 #1
0
        internal PSObjectDisposedException NewObjectDisposedException(
            string objectName)
        {
            string message = !string.IsNullOrEmpty(objectName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ObjectDisposed", (object)objectName) : throw this.NewArgumentNullException(nameof(objectName));
            PSObjectDisposedException disposedException = new PSObjectDisposedException(objectName, message);

            this.TraceException((Exception)disposedException);
            return(disposedException);
        }
예제 #2
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant uses the default
        /// ObjectDisposedException template text. This is not allowed to call
        /// other Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="objectName">
        /// The name of the disposed object
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        /// <remarks>
        /// Note that the parameter is the object name and not the message.
        /// </remarks>
        internal static PSObjectDisposedException NewObjectDisposedException(string objectName)
        {
            if (String.IsNullOrEmpty(objectName))
            {
                throw NewArgumentNullException("objectName");
            }
            string message = StringUtil.Format(AutomationExceptions.ObjectDisposed, objectName);
            var    e       = new PSObjectDisposedException(objectName, message);

            return(e);
        }
예제 #3
0
        /// <summary>
        /// Traces the Message and StackTrace properties of the exception
        /// and returns the new exception. This variant uses the default
        /// ObjectDisposedException template text. This is not allowed to call
        /// other Throw*Exception variants, since they call this.
        /// </summary>
        /// <param name="objectName">
        /// The name of the disposed object
        /// </param>
        /// <returns>Exception instance ready to throw</returns>
        /// <remarks>
        /// Note that the parameter is the object name and not the message.
        /// </remarks>
        internal static PSObjectDisposedException NewObjectDisposedException(string objectName)
        {
            if (String.IsNullOrEmpty(objectName))
            {
                throw NewArgumentNullException("objectName");
            }
            string message = StringUtil.Format(AutomationExceptions.ObjectDisposed, objectName);
            var e = new PSObjectDisposedException(objectName, message);

            return e;
        }