当前位置: 首页>>代码示例>>C#>>正文


C# Cmdlet.GetResourceString方法代码示例

本文整理汇总了C#中Cmdlet.GetResourceString方法的典型用法代码示例。如果您正苦于以下问题:C# Cmdlet.GetResourceString方法的具体用法?C# Cmdlet.GetResourceString怎么用?C# Cmdlet.GetResourceString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cmdlet的用法示例。


在下文中一共展示了Cmdlet.GetResourceString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildMessage

 private string BuildMessage(Cmdlet cmdlet, string baseName, string resourceId, params object[] args)
 {
     if (cmdlet == null)
     {
         throw PSTraceSource.NewArgumentNullException("cmdlet");
     }
     if (string.IsNullOrEmpty(baseName))
     {
         throw PSTraceSource.NewArgumentNullException("baseName");
     }
     if (string.IsNullOrEmpty(resourceId))
     {
         throw PSTraceSource.NewArgumentNullException("resourceId");
     }
     string template = "";
     try
     {
         template = cmdlet.GetResourceString(baseName, resourceId);
     }
     catch (MissingManifestResourceException exception)
     {
         this._textLookupError = exception;
         return "";
     }
     catch (ArgumentException exception2)
     {
         this._textLookupError = exception2;
         return "";
     }
     return this.BuildMessage(template, baseName, resourceId, args);
 }
开发者ID:nickchal,项目名称:pash,代码行数:31,代码来源:ErrorDetails.cs

示例2: GetHelpMessage

 internal string GetHelpMessage(Cmdlet cmdlet)
 {
     string helpMessage = null;
     bool flag = !string.IsNullOrEmpty(this.HelpMessage);
     bool flag2 = !string.IsNullOrEmpty(this.HelpMessageBaseName);
     bool flag3 = !string.IsNullOrEmpty(this.HelpMessageResourceId);
     if (flag2 ^ flag3)
     {
         throw PSTraceSource.NewArgumentException(flag2 ? "HelpMessageResourceId" : "HelpMessageBaseName");
     }
     if (flag2 && flag3)
     {
         try
         {
             return cmdlet.GetResourceString(this.HelpMessageBaseName, this.HelpMessageResourceId);
         }
         catch (ArgumentException)
         {
             if (!flag)
             {
                 throw;
             }
             return this.HelpMessage;
         }
         catch (InvalidOperationException)
         {
             if (!flag)
             {
                 throw;
             }
             return this.HelpMessage;
         }
     }
     if (flag)
     {
         helpMessage = this.HelpMessage;
     }
     return helpMessage;
 }
开发者ID:nickchal,项目名称:pash,代码行数:39,代码来源:ParameterSetSpecificMetadata.cs

示例3: BuildMessage

        private string BuildMessage(
            Cmdlet cmdlet,
            string baseName,
            string resourceId,
            params object[] args)
        {
            if (null == cmdlet)
                throw PSTraceSource.NewArgumentNullException("cmdlet");

            if (String.IsNullOrEmpty(baseName))
                throw PSTraceSource.NewArgumentNullException("baseName");

            if (String.IsNullOrEmpty(resourceId))
                throw PSTraceSource.NewArgumentNullException("resourceId");

            string template = "";

            try
            {
                template = cmdlet.GetResourceString(baseName, resourceId);
            }
            catch (MissingManifestResourceException e)
            {
                _textLookupError = e;
                return ""; // fallback to Exception.Message
            }
            catch (ArgumentException e)
            {
                _textLookupError = e;
                return ""; // fallback to Exception.Message
            }
            return BuildMessage(template, baseName, resourceId, args);
        } // BuildMessage
开发者ID:40a,项目名称:PowerShell,代码行数:33,代码来源:ErrorPackage.cs

示例4: GetHelpMessage

        /// <summary>
        /// If HelpMessageBaseName and HelpMessageResourceId are set, the help info is
        /// loaded from the resource indicated by HelpMessageBaseName and HelpMessageResourceId.
        /// If that fails and HelpMessage is set, the help info is set to HelpMessage; otherwise,
        /// the exception that is thrown when loading the resource is thrown.
        /// If both HelpMessageBaseName and HelpMessageResourceId are not set, the help info is
        /// set to HelpMessage
        /// </summary>
        /// 
        /// <returns>
        /// Help info about the parameter
        /// </returns>
        /// 
        /// <exception cref="InvalidOperationException">
        /// If the value of the specified resource is not a string and
        ///     HelpMessage is not set.
        /// </exception>
        /// 
        /// <exception cref="ArgumentException">
        /// If only one of HelpMessageBaseName and HelpMessageResourceId is set
        ///     OR if no usable resources have been found, and
        ///     there are no neutral culture resources and HelpMessage is not set.
        /// </exception>
        /// 
        internal string GetHelpMessage(Cmdlet cmdlet)
        {
            string helpInfo = null;
            bool isHelpMsgSet = !string.IsNullOrEmpty(HelpMessage);
            bool isHelpMsgBaseNameSet = !string.IsNullOrEmpty(HelpMessageBaseName);
            bool isHelpMsgResIdSet = !string.IsNullOrEmpty(HelpMessageResourceId);

            if (isHelpMsgBaseNameSet ^ isHelpMsgResIdSet)
            {
                throw PSTraceSource.NewArgumentException(isHelpMsgBaseNameSet ? "HelpMessageResourceId" : "HelpMessageBaseName");
            }

            if (isHelpMsgBaseNameSet && isHelpMsgResIdSet)
            {
                try
                {
                    helpInfo = cmdlet.GetResourceString(HelpMessageBaseName, HelpMessageResourceId);
                }
                catch (ArgumentException)
                {
                    if (isHelpMsgSet)
                    {
                        helpInfo = HelpMessage;
                    }
                    else
                    {
                        throw;
                    }
                }
                catch (InvalidOperationException)
                {
                    if (isHelpMsgSet)
                    {
                        helpInfo = HelpMessage;
                    }
                    else
                    {
                        throw;
                    }
                }
            }
            else if (isHelpMsgSet)
            {
                helpInfo = HelpMessage;
            }
            return helpInfo;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:71,代码来源:ParameterSetSpecificMetadata.cs


注:本文中的Cmdlet.GetResourceString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。