Beispiel #1
0
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(baseName));
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(resourceId));
         }
         ResourceManager resourceManager = ResourceManagerCache.GetResourceManager(this.GetType().Assembly, baseName);
         string          str;
         try
         {
             str = resourceManager.GetString(resourceId, Thread.CurrentThread.CurrentUICulture);
         }
         catch (MissingManifestResourceException ex)
         {
             throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(baseName), "GetErrorText", "ResourceBaseNameFailure", (object)baseName);
         }
         return(str != null ? str : throw CmdletProvider.providerBaseTracer.NewArgumentException(nameof(resourceId), "GetErrorText", "ResourceIdFailure", (object)resourceId));
     }
 }
Beispiel #2
0
 public virtual string GetResourceString(string baseName, string resourceId)
 {
     using (PSTransactionManager.GetEngineProtectionScope())
     {
         if (string.IsNullOrEmpty(baseName))
         {
             throw PSTraceSource.NewArgumentException("baseName");
         }
         if (string.IsNullOrEmpty(resourceId))
         {
             throw PSTraceSource.NewArgumentException("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);
     }
 }