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); } }
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)); } }
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)); }
internal EventLogLogProvider(string shellId) { string str = this.SetupEventSource(shellId); this._eventLog = new EventLog(); this._eventLog.Source = str; this._resourceManager = ResourceManagerCache.GetResourceManager(Assembly.GetExecutingAssembly(), "Logging"); }
internal static ResourceManager GetResourceManager(string baseName) { using (ResourceManagerCache.tracer.TraceMethod()) return(!string.IsNullOrEmpty(baseName) ? ResourceManagerCache.GetResourceManager(Assembly.GetCallingAssembly(), baseName) : throw ResourceManagerCache.tracer.NewArgumentException(nameof(baseName))); }