コード例 #1
0
ファイル: ErrorDetails.cs プロジェクト: modulexcite/pash-1
        private string BuildMessage(Assembly assembly, string baseName, string resourceId, params object[] args)
        {
            if (null == assembly)
            {
                throw PSTraceSource.NewArgumentNullException("assembly");
            }
            if (string.IsNullOrEmpty(baseName))
            {
                throw PSTraceSource.NewArgumentNullException("baseName");
            }
            if (string.IsNullOrEmpty(resourceId))
            {
                throw PSTraceSource.NewArgumentNullException("resourceId");
            }
            string          template        = "";
            ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(assembly, baseName);

            try
            {
                template = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
            }
            catch (MissingManifestResourceException exception)
            {
                this._textLookupError = exception;
                return("");
            }
            return(this.BuildMessage(template, baseName, resourceId, args));
        }
コード例 #2
0
 private string BuildMessage()
 {
     try
     {
         object[] array = new object[0];
         if (this.args != null)
         {
             array    = new object[this.args.Length + 6];
             array[0] = this.commandName;
             array[1] = this.parameterName;
             array[2] = this.parameterType;
             array[3] = this.typeSpecified;
             array[4] = this.line;
             array[5] = this.offset;
             this.args.CopyTo(array, 6);
         }
         string str = string.Empty;
         if (!string.IsNullOrEmpty(this.resourceBaseName) && !string.IsNullOrEmpty(this.resourceId))
         {
             str = ResourceManagerCache.FormatResourceString(this.resourceBaseName, this.resourceId, array);
         }
         return(str);
     }
     catch (MissingManifestResourceException exception)
     {
         return(ResourceManagerCache.FormatResourceString("ParameterBinderStrings", "ResourceStringLoadError", new object[] { this.args[0], this.resourceBaseName, this.resourceId, exception.Message }));
     }
     catch (FormatException exception2)
     {
         return(ResourceManagerCache.FormatResourceString("ParameterBinderStrings", "ResourceStringFormatError", new object[] { this.args[0], this.resourceBaseName, this.resourceId, exception2.Message }));
     }
 }
コード例 #3
0
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw Cmdlet.tracer.NewArgumentNullException(nameof(baseName));
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw Cmdlet.tracer.NewArgumentNullException(nameof(resourceId));
         }
         ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(this.GetType().Assembly, baseName);
         string          str;
         try
         {
             str = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
         }
         catch (MissingManifestResourceException ex)
         {
             throw Cmdlet.tracer.NewArgumentException(nameof(baseName), "GetErrorText", "ResourceBaseNameFailure", (object)baseName);
         }
         return(str != null ? str : throw Cmdlet.tracer.NewArgumentException(nameof(resourceId), "GetErrorText", "ResourceIdFailure", (object)resourceId));
     }
 }
コード例 #4
0
        internal static RuntimeException NewInterpreterExceptionWithInnerException(
            object targetObject,
            Type exceptionType,
            Token errToken,
            string resourceIdAndErrorId,
            Exception innerException,
            params object[] args)
        {
            if (string.IsNullOrEmpty(resourceIdAndErrorId))
            {
                throw InterpreterError.tracer.NewArgumentException(nameof(resourceIdAndErrorId));
            }
            RuntimeException runtimeException;

            try
            {
                string message = args == null || args.Length == 0 ? ResourceManagerCache.GetResourceString("Parser", resourceIdAndErrorId) : ResourceManagerCache.FormatResourceString("Parser", resourceIdAndErrorId, args);
                runtimeException = !string.IsNullOrEmpty(message) ? InterpreterError.NewInterpreterExceptionByMessage(exceptionType, errToken, message, resourceIdAndErrorId, innerException) : InterpreterError.NewBackupInterpreterException(exceptionType, errToken, resourceIdAndErrorId, (Exception)null);
            }
            catch (InvalidOperationException ex)
            {
                runtimeException = InterpreterError.NewBackupInterpreterException(exceptionType, errToken, resourceIdAndErrorId, (Exception)ex);
            }
            catch (MissingManifestResourceException ex)
            {
                runtimeException = InterpreterError.NewBackupInterpreterException(exceptionType, errToken, resourceIdAndErrorId, (Exception)ex);
            }
            catch (FormatException ex)
            {
                runtimeException = InterpreterError.NewBackupInterpreterException(exceptionType, errToken, resourceIdAndErrorId, (Exception)ex);
            }
            runtimeException.SetTargetObject(targetObject);
            return(runtimeException);
        }
コード例 #5
0
        internal static Encoding Convert(Cmdlet cmdlet, string encoding)
        {
            switch (encoding)
            {
            case "":
            case null:
                return(Encoding.Unicode);

            default:
                if (string.Equals(encoding, "unicode", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.Unicode);
                }
                if (string.Equals(encoding, "bigendianunicode", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.BigEndianUnicode);
                }
                if (string.Equals(encoding, "ascii", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.ASCII);
                }
                if (string.Equals(encoding, "utf8", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF8);
                }
                if (string.Equals(encoding, "utf7", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF7);
                }
                if (string.Equals(encoding, "utf32", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.UTF32);
                }
                if (string.Equals(encoding, "default", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.Default);
                }
                if (string.Equals(encoding, "oem", StringComparison.OrdinalIgnoreCase))
                {
                    return(Encoding.GetEncoding((int)EncodingConversion.NativeMethods.GetOEMCP()));
                }
                string str = string.Join(", ", new string[8]
                {
                    "unicode",
                    "bigendianunicode",
                    "ascii",
                    "utf8",
                    "utf7",
                    "utf32",
                    "default",
                    "oem"
                });
                string message = ResourceManagerCache.FormatResourceString("PathUtils", "OutFile_WriteToFileEncodingUnknown", (object)encoding, (object)str);
                cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)EncodingConversion.tracer.NewArgumentException("Encoding"), "WriteToFileEncodingUnknown", ErrorCategory.InvalidArgument, (object)null)
                {
                    ErrorDetails = new ErrorDetails(message)
                });
                return((Encoding)null);
            }
        }
コード例 #6
0
        private ActionPreference InquireForActionPreference(
            string message,
            ExecutionContext context)
        {
            InternalHostUserInterface      ui      = (InternalHostUserInterface)context.EngineHostInterface.UI;
            Collection <ChoiceDescription> choices = new Collection <ChoiceDescription>();
            string resourceString1 = ResourceManagerCache.GetResourceString("Parser", "ContinueLabel");
            string resourceString2 = ResourceManagerCache.GetResourceString("Parser", "ContinueHelpMessage");
            string resourceString3 = ResourceManagerCache.GetResourceString("Parser", "SilentlyContinueLabel");
            string resourceString4 = ResourceManagerCache.GetResourceString("Parser", "SilentlyContinueHelpMessage");
            string resourceString5 = ResourceManagerCache.GetResourceString("Parser", "BreakLabel");
            string resourceString6 = ResourceManagerCache.GetResourceString("Parser", "BreakHelpMessage");
            string resourceString7 = ResourceManagerCache.GetResourceString("Parser", "SuspendLabel");
            string helpMessage     = ResourceManagerCache.FormatResourceString("Parser", "SuspendHelpMessage");

            choices.Add(new ChoiceDescription(resourceString1, resourceString2));
            choices.Add(new ChoiceDescription(resourceString3, resourceString4));
            choices.Add(new ChoiceDescription(resourceString5, resourceString6));
            choices.Add(new ChoiceDescription(resourceString7, helpMessage));
            string resourceString8 = ResourceManagerCache.GetResourceString("Parser", "ExceptionActionPromptCaption");
            int    num;

            while ((num = ui.PromptForChoice(resourceString8, message, choices, 0)) == 3)
            {
                context.EngineHostInterface.EnterNestedPrompt();
            }
            if (num == 0)
            {
                return(ActionPreference.Continue);
            }
            return(num == 1 ? ActionPreference.SilentlyContinue : ActionPreference.Stop);
        }
コード例 #7
0
        internal void ShouldRunInternal(CommandInfo commandInfo, CommandOrigin origin, PSHost host)
        {
            Exception reason = (Exception)null;
            bool      flag;

            try
            {
                flag = this.ShouldRun(commandInfo, origin, host, out reason);
            }
            catch (Exception ex)
            {
                CommandProcessorBase.CheckForSevereException(ex);
                flag   = false;
                reason = (Exception)null;
            }
            if (flag)
            {
                return;
            }
            if (reason == null)
            {
                throw new PSSecurityException(ResourceManagerCache.GetResourceString("AuthorizationManagerBase", "AuthorizationManagerDefaultFailureReason"));
            }
            if (reason is PSSecurityException)
            {
                AuthorizationManager.tracer.TraceException(reason);
                throw reason;
            }
            PSSecurityException securityException = new PSSecurityException(reason.Message, reason);

            AuthorizationManager.tracer.TraceException((Exception)securityException);
            throw securityException;
        }
コード例 #8
0
        private static string BuildMessage(string commandName, Collection <string> missingPSSnapIns)
        {
            string        resourceId    = "RequiresMissingPSSnapIns";
            StringBuilder stringBuilder = new StringBuilder();

            if (missingPSSnapIns == null)
            {
                throw ScriptRequiresException.tracer.NewArgumentNullException(nameof(missingPSSnapIns));
            }
            foreach (string missingPsSnapIn in missingPSSnapIns)
            {
                stringBuilder.Append(missingPsSnapIn).Append(", ");
            }
            if (stringBuilder.Length > 1)
            {
                stringBuilder.Remove(stringBuilder.Length - 2, 2);
            }
            try
            {
                return(ResourceManagerCache.FormatResourceString("DiscoveryExceptions", resourceId, (object)commandName, (object)stringBuilder.ToString()));
            }
            catch (MissingManifestResourceException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringLoadError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
            catch (FormatException ex)
            {
                ScriptRequiresException.tracer.TraceException((Exception)ex);
                return(ResourceManagerCache.FormatResourceString("SessionStateStrings", "ResourceStringFormatError", (object)commandName, (object)"DiscoveryExceptions", (object)resourceId, (object)ex.Message));
            }
        }
コード例 #9
0
ファイル: JobManager.cs プロジェクト: modulexcite/pash-1
        public Job2 NewJob(JobInvocationInfo specification)
        {
            if (specification == null)
            {
                throw new ArgumentNullException("specification");
            }
            if (specification.Definition == null)
            {
                throw new ArgumentException(ResourceManagerCache.GetResourceString("RemotingErrorIdStrings", "NewJobSpecificationError"), "specification");
            }
            JobSourceAdapter jobSourceAdapter = this.GetJobSourceAdapter(specification.Definition);
            Job2             job = null;

            try
            {
                job = jobSourceAdapter.NewJob(specification);
            }
            catch (Exception exception)
            {
                this.Tracer.TraceException(exception);
                CommandProcessorBase.CheckForSevereException(exception);
                throw;
            }
            return(job);
        }
コード例 #10
0
ファイル: PSTraceSource.cs プロジェクト: mmoenfly/GitCook2021
        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);
        }
コード例 #11
0
ファイル: PSTraceSource.cs プロジェクト: mmoenfly/GitCook2021
        internal PSNotSupportedException NewNotSupportedException()
        {
            PSNotSupportedException supportedException = new PSNotSupportedException(ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "NotSupported", (object)new StackTrace().GetFrame(0).ToString()));

            this.TraceException((Exception)supportedException);
            return(supportedException);
        }
コード例 #12
0
        private void VerifyValue(object value)
        {
            if (value == null)
            {
                return;
            }
            value = PSObject.Base(value);
            Type type = value.GetType();

            foreach (Type handshakeFriendlyType in PSPrimitiveDictionary.handshakeFriendlyTypes)
            {
                if (type == handshakeFriendlyType)
                {
                    return;
                }
            }
            if (type.IsArray || type.Equals(typeof(ArrayList)))
            {
                foreach (object obj in (IEnumerable)value)
                {
                    this.VerifyValue(obj);
                }
            }
            else
            {
                throw new ArgumentException(ResourceManagerCache.FormatResourceString("Serialization", "PrimitiveHashtableInvalidValue", (object)value.GetType().FullName));
            }
        }
コード例 #13
0
ファイル: Cmdlet.cs プロジェクト: modulexcite/pash-1
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw PSTraceSource.NewArgumentNullException("baseName");
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw PSTraceSource.NewArgumentNullException("resourceId");
         }
         ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(base.GetType().Assembly, baseName);
         string          str             = null;
         try
         {
             str = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
         }
         catch (MissingManifestResourceException)
         {
             throw PSTraceSource.NewArgumentException("baseName", "GetErrorText", "ResourceBaseNameFailure", new object[] { baseName });
         }
         if (str == null)
         {
             throw PSTraceSource.NewArgumentException("resourceId", "GetErrorText", "ResourceIdFailure", new object[] { resourceId });
         }
         return(str);
     }
 }
コード例 #14
0
        private void ProcessNewSubscriber(
            PSEventSubscriber subscriber,
            object source,
            string eventName,
            string sourceIdentifier,
            PSObject data,
            bool supportEvent,
            bool forwardEvent)
        {
            Delegate handler = (Delegate)null;

            if (this.eventAssembly == null)
            {
                this.debugMode     = new StackFrame(0, true).GetFileName() != null;
                this.eventAssembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("PSEventHandler"), AssemblyBuilderAccess.Run);
            }
            if (this.eventModule == null)
            {
                this.eventModule = this.eventAssembly.DefineDynamicModule("PSGenericEventModule", this.debugMode);
            }
            if (source != null)
            {
                if (!(source is Type type))
                {
                    type = source.GetType();
                }
                BindingFlags bindingAttr = BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public;
                EventInfo    eventInfo   = type.GetEvent(eventName, bindingAttr);
                if (eventInfo == null)
                {
                    throw new ArgumentException(ResourceManagerCache.FormatResourceString("EventingResources", "CouldNotFindEvent", (object)eventName), nameof(eventName));
                }
                if (sourceIdentifier != null && sourceIdentifier.StartsWith("PowerShell.", StringComparison.OrdinalIgnoreCase))
                {
                    throw new ArgumentException(ResourceManagerCache.FormatResourceString("EventingResources", "ReservedIdentifier", (object)sourceIdentifier), nameof(sourceIdentifier));
                }
                if (type.GetProperty("EnableRaisingEvents") != null)
                {
                    type.InvokeMember("EnableRaisingEvents", BindingFlags.SetProperty, (Binder)null, source, new object[1]
                    {
                        (object)true
                    }, CultureInfo.CurrentCulture);
                }
                if (source is ManagementEventWatcher managementEventWatcher)
                {
                    managementEventWatcher.Start();
                }
                MethodInfo method = eventInfo.EventHandlerType.GetMethod("Invoke");
                if (method.ReturnType != typeof(void))
                {
                    throw new ArgumentException(ResourceManagerCache.GetResourceString("EventingResources", "NonVoidDelegateNotSupported"), nameof(eventName));
                }
                object eventHandler = this.GenerateEventHandler((PSEventManager)this, source, sourceIdentifier, data, method);
                handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, eventHandler, "EventDelegate");
                eventInfo.AddEventHandler(source, handler);
            }
            lock (this.eventSubscribers)
                this.eventSubscribers[subscriber] = handler;
        }
コード例 #15
0
 private static string BuildPSSnapInDisplayName(PSSnapInNameVersionPair PSSnapin)
 {
     if (PSSnapin.Version == (Version)null)
     {
         return(PSSnapin.PSSnapInName);
     }
     return(ResourceManagerCache.FormatResourceString("DiscoveryExceptions", "PSSnapInNameVersion", (object)PSSnapin.PSSnapInName, (object)PSSnapin.Version));
 }
コード例 #16
0
        internal EventLogLogProvider(string shellId)
        {
            string str = this.SetupEventSource(shellId);

            this._eventLog        = new EventLog();
            this._eventLog.Source = str;
            this._resourceManager = ResourceManagerCache.GetResourceManager(Assembly.GetExecutingAssembly(), "Logging");
        }
コード例 #17
0
ファイル: PSTraceSource.cs プロジェクト: mmoenfly/GitCook2021
        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);
        }
コード例 #18
0
ファイル: PathUtils.cs プロジェクト: mmoenfly/GitCook2021
        internal static void ReportWildcardingFailure(Cmdlet cmdlet, string filePath)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_DidNotResolveFile", (object)filePath);

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception) new FileNotFoundException(), "FileOpenFailure", ErrorCategory.OpenError, (object)filePath)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
コード例 #19
0
ファイル: PathUtils.cs プロジェクト: mmoenfly/GitCook2021
        internal static void ReportMultipleFilesNotSupported(Cmdlet cmdlet)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_MultipleFilesNotSupported");

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)PathUtils.tracer.NewInvalidOperationException(), "ReadWriteMultipleFilesNotSupported", ErrorCategory.InvalidArgument, (object)null)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
コード例 #20
0
ファイル: PathUtils.cs プロジェクト: mmoenfly/GitCook2021
        internal static void ReportWrongProviderType(Cmdlet cmdlet, string providerId)
        {
            string message = ResourceManagerCache.FormatResourceString(nameof(PathUtils), "OutFile_ReadWriteFileNotFileSystemProvider", (object)providerId);

            cmdlet.ThrowTerminatingError(new ErrorRecord((Exception)PathUtils.tracer.NewInvalidOperationException(), "ReadWriteFileNotFileSystemProvider", ErrorCategory.InvalidArgument, (object)null)
            {
                ErrorDetails = new ErrorDetails(message)
            });
        }
コード例 #21
0
ファイル: PSTraceSource.cs プロジェクト: mmoenfly/GitCook2021
        internal PSArgumentNullException NewArgumentNullException(
            string paramName)
        {
            string message = !string.IsNullOrEmpty(paramName) ? ResourceManagerCache.FormatResourceString(Assembly.GetAssembly(typeof(PSObject)), "AutomationExceptions", "ArgumentNull", (object)paramName) : throw new ArgumentNullException(nameof(paramName));
            PSArgumentNullException argumentNullException = new PSArgumentNullException(paramName, message);

            this.TraceException((Exception)argumentNullException);
            return(argumentNullException);
        }
コード例 #22
0
 public override PSEventSubscriber SubscribeEvent(
     object source,
     string eventName,
     string sourceIdentifier,
     PSObject data,
     PSEventReceivedEventHandler handlerDelegate,
     bool supportEvent,
     bool forwardEvent)
 {
     throw new NotSupportedException(ResourceManagerCache.GetResourceString("EventingResources", "RemoteOperationNotSupported"));
 }
コード例 #23
0
 internal ScriptBlockToPowerShellNotSupportedException(
     string errorId,
     Exception innerException,
     string baseName,
     string resourceId,
     params object[] arguments)
     : base(ResourceManagerCache.FormatResourceString(baseName, resourceId, arguments), innerException)
 {
     this.SetErrorId(errorId);
     ScriptBlockToPowerShellNotSupportedException.tracer.TraceException((Exception)this);
 }
コード例 #24
0
ファイル: JobManager.cs プロジェクト: modulexcite/pash-1
        internal void RegisterJobSourceAdapter(Type jobSourceAdapterType)
        {
            object obj2 = null;

            if ((jobSourceAdapterType.FullName != null) && jobSourceAdapterType.FullName.EndsWith("WorkflowJobSourceAdapter", StringComparison.OrdinalIgnoreCase))
            {
                obj2 = jobSourceAdapterType.GetMethod("GetInstance").Invoke(null, null);
            }
            else
            {
                ConstructorInfo constructor = jobSourceAdapterType.GetConstructor(Type.EmptyTypes);
                if (!constructor.IsPublic)
                {
                    throw new InvalidOperationException(ResourceManagerCache.FormatResourceString("RemotingErrorIdStrings", "JobManagerRegistrationConstructorError", new object[] { jobSourceAdapterType.FullName }));
                }
                try
                {
                    obj2 = constructor.Invoke(null);
                }
                catch (MemberAccessException exception)
                {
                    this.Tracer.TraceException(exception);
                    throw;
                }
                catch (TargetInvocationException exception2)
                {
                    this.Tracer.TraceException(exception2);
                    throw;
                }
                catch (TargetParameterCountException exception3)
                {
                    this.Tracer.TraceException(exception3);
                    throw;
                }
                catch (NotSupportedException exception4)
                {
                    this.Tracer.TraceException(exception4);
                    throw;
                }
                catch (SecurityException exception5)
                {
                    this.Tracer.TraceException(exception5);
                    throw;
                }
            }
            if (obj2 != null)
            {
                lock (this._syncObject)
                {
                    this._sourceAdapters.Add(jobSourceAdapterType.Name, (JobSourceAdapter)obj2);
                }
            }
        }
コード例 #25
0
ファイル: PSTraceSource.cs プロジェクト: modulexcite/pash-1
 internal static PSInvalidOperationException NewInvalidOperationException(Exception innerException, string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSInvalidOperationException(ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args), innerException));
 }
コード例 #26
0
ファイル: PSTraceSource.cs プロジェクト: modulexcite/pash-1
 internal static PSNotSupportedException NewNotSupportedException(string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSNotSupportedException(ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args)));
 }
コード例 #27
0
 internal MetadataException(
     string errorId,
     Exception innerException,
     string baseName,
     string resourceId,
     params object[] arguments)
     : base(ResourceManagerCache.FormatResourceString(baseName, resourceId, arguments), innerException)
 {
     this.SetErrorCategory(ErrorCategory.MetadataError);
     this.SetErrorId(errorId);
     MetadataException.tracer.TraceException((Exception)this);
 }
コード例 #28
0
 internal static ResourceManager GetResourceManager(
     Assembly assembly,
     string baseName)
 {
     using (ResourceManagerCache.tracer.TraceMethod())
     {
         if (assembly == null)
         {
             throw ResourceManagerCache.tracer.NewArgumentNullException(nameof(assembly));
         }
         if (string.IsNullOrEmpty(baseName))
         {
             throw ResourceManagerCache.tracer.NewArgumentException(nameof(baseName));
         }
         ResourceManager resourceManager = (ResourceManager)null;
         Dictionary <string, ResourceManager> dictionary1 = (Dictionary <string, ResourceManager>)null;
         lock (ResourceManagerCache.syncRoot)
         {
             if (ResourceManagerCache.resourceManagerCache.ContainsKey(assembly.Location))
             {
                 dictionary1 = ResourceManagerCache.resourceManagerCache[assembly.Location];
                 if (dictionary1 != null)
                 {
                     if (dictionary1.ContainsKey(baseName))
                     {
                         resourceManager = dictionary1[baseName];
                     }
                 }
             }
         }
         if (resourceManager == null)
         {
             ResourceManagerCache.tracer.WriteLine("Initializing new ResourceManager instance", new object[0]);
             ResourceManagerCache.tracer.WriteLine("Resource base name: {0}", (object)baseName);
             ResourceManagerCache.tracer.WriteLine("Resource assembly location: {0}", (object)assembly.Location);
             resourceManager = ResourceManagerCache.InitRMWithAssembly(baseName, assembly, (Type)null);
             if (dictionary1 != null)
             {
                 lock (ResourceManagerCache.syncRoot)
                     dictionary1[baseName] = resourceManager;
             }
             else
             {
                 Dictionary <string, ResourceManager> dictionary2 = new Dictionary <string, ResourceManager>();
                 dictionary2[baseName] = resourceManager;
                 lock (ResourceManagerCache.syncRoot)
                     ResourceManagerCache.resourceManagerCache[assembly.Location] = dictionary2;
             }
         }
         return(resourceManager);
     }
 }
コード例 #29
0
ファイル: JobManager.cs プロジェクト: modulexcite/pash-1
        private JobSourceAdapter AssertAndReturnJobSourceAdapter(string adapterTypeName)
        {
            JobSourceAdapter adapter;

            lock (this._syncObject)
            {
                if (!this._sourceAdapters.TryGetValue(adapterTypeName, out adapter))
                {
                    throw new InvalidOperationException(ResourceManagerCache.GetResourceString("RemotingErrorIdStrings", "JobSourceAdapterNotFound"));
                }
            }
            return(adapter);
        }
コード例 #30
0
ファイル: PSTraceSource.cs プロジェクト: modulexcite/pash-1
 internal static PSArgumentOutOfRangeException NewArgumentOutOfRangeException(string paramName, object actualValue, string baseName, string resourceId, params object[] args)
 {
     if (string.IsNullOrEmpty(paramName))
     {
         throw NewArgumentNullException("paramName");
     }
     if (string.IsNullOrEmpty(baseName))
     {
         throw NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw NewArgumentNullException("resourceId");
     }
     return(new PSArgumentOutOfRangeException(paramName, actualValue, ResourceManagerCache.FormatResourceString(Assembly.GetCallingAssembly(), baseName, resourceId, args)));
 }