本文整理汇总了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;
}
}
示例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));
}
示例3: Write
public void Write(Cmdlet cmd, string response)
{
cmd.WriteVerbose(response);
}
示例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:
//.........这里部分代码省略.........