"景先生毕设|www.jxszl.com

C# Cmdlet类代码示例

2023-12-29 17:44编辑: www.jxszl.com景先生毕设
本文整理汇总了C#中Cmdlet类的典型用法代码示例。如果您正苦于以下问题:C#Cmdlet类的具体用法?C#Cmdlet怎么用?C#Cmdlet使用的例子?这里精选的类代码示例或许可以为您提供帮助。 示例1:WarnAboutUnsupportedActionPreferences privatestaticvoidWarnAboutUnsupportedActionPreferences( Cmdletcmdlet, ActionPreferenceeffectiveActionPreference, stringnameOfCommandLineParameter, FuncinquireMessageGetter, FuncstopMessageGetter) { stringmessage; switch(effectiveActionPreference) { caseActionPreference.Stop: message=stopMessageGetter(); break; caseActionPreference.Inquire: message=inquireMessageGetter(); break; default: return;//wecanhandleeverythingthatisnotStoporInquire } boolactionPreferenceComesFromCommandLineParameter=cmdlet.MyInvocation.BoundParameters.ContainsKey(nameOfCommandLineParameter); if(actionPreferenceComesFromCommandLineParameter) { Exceptionexception=newArgumentException(message); ErrorRecorderrorRecord=newErrorRecord(exception,"ActionPreferenceNotSupportedByCimCmdletAdapter",ErrorCategory.NotImplemented,null); cmdlet.ThrowTerminatingError(errorRecord); } }
原文链接:http://www.jxszl.com/biancheng/C/556784.html