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


C# Cmdlet.WriteVerbose方法代码示例

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


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

示例1: Handle

 /// <summary>
 /// Output a message in the appropriate way in a powershell command
 /// </summary>
 /// <param name="caller">the Cmdlet object running</param>
 /// <param name="e">the event containing the message</param>
 public static void Handle(Cmdlet caller, MessageEventArgs e)
 {
     switch (e.MessageType)
     {
         case MessageType.Verbose:
             caller.WriteVerbose(e.Message);
             break;
         case MessageType.Progress:
             caller.WriteProgress(new ProgressRecord(0, e.Activity, e.Message));
             break;
         case MessageType.Error:
             ToolsHelper.WriteException(caller, e.Exception);
             caller.ThrowTerminatingError(new ErrorRecord(e.Exception, "0", ErrorCategory.InvalidOperation, caller));
             break;
         case MessageType.Output:
             caller.WriteObject(e.Message);
             break;
     }
 }
开发者ID:jamesej,项目名称:lynicon,代码行数:24,代码来源:MessageHandler.cs

示例2: WriteException

 /// <summary>
 /// Write out an exception to the Verbose output channel
 /// </summary>
 /// <param name="caller"></param>
 /// <param name="ex"></param>
 public static void WriteException(Cmdlet caller, Exception ex)
 {
     if (ex.InnerException != null)
         WriteException(caller, ex.InnerException);
     caller.WriteVerbose(string.Format("Exception was: {0} at: {1}", ex.Message, ex.StackTrace));
 }
开发者ID:jamesej,项目名称:lynicon,代码行数:11,代码来源:ToolsHelper.cs

示例3: Write

 public void Write(Cmdlet cmd, string response)
 {
     cmd.WriteVerbose(response);
 }
开发者ID:brianhartsock,项目名称:powershell-rackspaceapps,代码行数:4,代码来源:VerboseOutputWriter.cs

示例4: AssignNewValue

        public void AssignNewValue(Cmdlet myCmdlet, attributeSchema prop, card so, object newValue)
        {
            if (newValue == null) { return; } // Hacky Workaround
            var lists = so.attributeList != null ? so.attributeList.ToList() : new List<attribute>();

            myCmdlet.WriteVerbose("Want to set " + prop.name + " to " + newValue.ToString());

            var dict = lists.ToDictionary(key => key.name, value => value);
            var as1 = new attribute{ name = prop.name};
            switch (prop.type)
            {
                case  "DATE":
                    string valtoset = newValue != null ? newValue.ToString() : null;
                    if (!string.IsNullOrEmpty(valtoset))
                    {
                        try
                        {
                            myCmdlet.WriteVerbose("DATE: Convert string to DateTimeObject");
                            DateTime xd = DateTime.Parse(valtoset.ToString(), CultureInfo.CurrentCulture);
                            as1.value = xd.ToString("yyyy-MM-ddThh:mm:ssZ");
                        }
                        catch (Exception e) { myCmdlet.WriteWarning(e.Message); }
                    }
                    break;
                case "TIMESTAMP":
                    string datetimetoset = newValue != null ? newValue.ToString() : null;
                    if (!string.IsNullOrEmpty(datetimetoset))
                    {
                        try
                        {
                            myCmdlet.WriteVerbose("TIMESTAMP: Convert string to DateTimeObject -> _" + datetimetoset.ToString() +"_");
                            DateTime xd = DateTime.Parse(datetimetoset.ToString(), CultureInfo.CurrentCulture);
                            as1.value = xd.ToString("yyyy-MM-ddThh:mm:ssZ");
                        }
                        catch (Exception e) { myCmdlet.WriteWarning(e.Message); }
                    }
                    break;
                case "REFERENCE":
                    if (prop.referencedIdClassSpecified && newValue.ToString().Length > 0)
                    {

                        int codeint = 0;
                        int.TryParse(newValue.ToString(), out codeint);
                        if (codeint == 0)
                        {
                            myCmdlet.WriteVerbose("Try it with Workaround Parent Class: " + prop.referencedClassName);
                            int tmpvalue = 0;
                            var parentclass = _clientconnection.getAttributeList(prop.referencedClassName);
                            foreach (attributeSchema attributeschema in parentclass)
                            {
                                if (attributeschema.name == as1.name)
                                {
                                    string newclassname = attributeschema.referencedClassName;
                                    myCmdlet.WriteVerbose("Try it with Fulltext search classname: " + newclassname);
                                    tmpvalue = GetCardbyCode(newclassname, newValue.ToString());
                                    if (tmpvalue == 0)
                                    {
                                        myCmdlet.WriteWarning("Reference Card not found: " + newValue.ToString());
                                        dict.Remove(as1.name);
                                    }
                                    else
                                    {
                                        myCmdlet.WriteVerbose("Card found: " + tmpvalue);
                                        newValue = tmpvalue;
                                    }

                                    break;
                                }
                            }

                            if (tmpvalue == 0)
                            {
                                myCmdlet.WriteVerbose("Fulltext search ReferenceCard: " + newValue.ToString());
                                myCmdlet.WriteVerbose("Fulltext search classname: " + prop.referencedClassName);
                                tmpvalue = GetCardbyCode(prop.referencedClassName, newValue.ToString());
                                newValue = tmpvalue;
                            }
                            else
                            {
                                myCmdlet.WriteVerbose("Card found Set to Value: " + tmpvalue);
                                newValue = tmpvalue;
                            }

                        }
                        else
                        {

                            //myCmdlet.WriteVerbose("Check if ReferenceCard exists: " + codeint);
                            //var check = _clientconnection.getCard(prop.referencedClassName, codeint, null);
                            //if (check == null)
                            //{
                            //    myCmdlet.WriteWarning("Reference Card not found: " + codeint);
                            //    dict.Remove(as1.name);
                            //}
                        }
                        as1.value = newValue.ToString();

                    }
                    break;
                default:
//.........这里部分代码省略.........
开发者ID:simonfuhrer,项目名称:CMDBLets,代码行数:101,代码来源:EntityTypes.cs


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