• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Automation.ScriptBlock类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Management.Automation.ScriptBlock的典型用法代码示例。如果您正苦于以下问题:C# ScriptBlock类的具体用法?C# ScriptBlock怎么用?C# ScriptBlock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScriptBlock类属于System.Management.Automation命名空间,在下文中一共展示了ScriptBlock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: CimActivityImplementationContext

		public CimActivityImplementationContext(ActivityImplementationContext activityImplementationContext, string computerName, PSCredential credential, string certificateThumbprint, AuthenticationMechanism? authenticationMechanism, bool useSsl, uint port, PSSessionOption sessionOption, CimSession session, CimSessionOptions cimSessionOptions, string moduleDefinition, Uri resourceUri)
		{
			if (activityImplementationContext != null)
			{
				base.PowerShellInstance = activityImplementationContext.PowerShellInstance;
				this.ResourceUri = resourceUri;
				this.ComputerName = computerName;
				base.PSCredential = credential;
				base.PSCertificateThumbprint = certificateThumbprint;
				base.PSAuthentication = authenticationMechanism;
				base.PSUseSsl = new bool?(useSsl);
				base.PSPort = new uint?(port);
				base.PSSessionOption = sessionOption;
				this.Session = session;
				this.SessionOptions = cimSessionOptions;
				if (moduleDefinition != null)
				{
					CimActivityImplementationContext._moduleScriptBlock = ScriptBlock.Create(moduleDefinition);
					this._moduleDefinition = moduleDefinition;
				}
				return;
			}
			else
			{
				throw new ArgumentNullException("activityImplementationContext");
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:27,代码来源:CimActivityImplementationContext.cs


示例2: SessionStateFunctionEntry

 internal SessionStateFunctionEntry(string name, string definition, ScopedItemOptions options, SessionStateEntryVisibility visibility, System.Management.Automation.ScriptBlock scriptBlock, string helpFile) : base(name, visibility)
 {
     this._definition = definition;
     this._options = options;
     this._scriptBlock = scriptBlock;
     this._helpFile = helpFile;
 }
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:SessionStateFunctionEntry.cs


示例3: InvokeScript

 private static object InvokeScript(string methodName, ScriptBlock script, object @this, object[] arguments)
 {
     object obj2;
     try
     {
         obj2 = script.DoInvokeReturnAsIs(true, ScriptBlock.ErrorHandlingBehavior.WriteToExternalErrorPipe, AutomationNull.Value, AutomationNull.Value, @this, arguments);
     }
     catch (SessionStateOverflowException exception)
     {
         throw new MethodInvocationException("ScriptMethodSessionStateOverflowException", exception, ExtendedTypeSystem.MethodInvocationException, new object[] { methodName, arguments.Length, exception.Message });
     }
     catch (RuntimeException exception2)
     {
         throw new MethodInvocationException("ScriptMethodRuntimeException", exception2, ExtendedTypeSystem.MethodInvocationException, new object[] { methodName, arguments.Length, exception2.Message });
     }
     catch (TerminateException)
     {
         throw;
     }
     catch (FlowControlException exception3)
     {
         throw new MethodInvocationException("ScriptMethodFlowControlException", exception3, ExtendedTypeSystem.MethodInvocationException, new object[] { methodName, arguments.Length, exception3.Message });
     }
     catch (PSInvalidOperationException exception4)
     {
         throw new MethodInvocationException("ScriptMethodInvalidOperationException", exception4, ExtendedTypeSystem.MethodInvocationException, new object[] { methodName, arguments.Length, exception4.Message });
     }
     return obj2;
 }
开发者ID:nickchal,项目名称:pash,代码行数:29,代码来源:PSScriptMethod.cs


示例4: DynamicVariable

 /// <summary>
 /// </summary>
 /// <param name="name">The name of the variable, without the preceeding $.</param>
 /// <param name="onGet">The get accessor for the variable. The return value will be used as the variable's value.</param>
 /// <param name="onSet">The set accessor for the variable. Use $Args[0] to access the new variable.</param>
 /// <param name="isCollection">True to wrap the value of the variable in a collection even if only a single value is returned.</param>
 public DynamicVariable(string name, ScriptBlock onGet, ScriptBlock onSet, bool isCollection)
     : base(name, null, ScopedItemOptions.AllScope)
 {
     OnGet = onGet;
     OnSet = onSet;
     IsCollection = isCollection;
 }
开发者ID:josheinstein,项目名称:PowerShell-Einstein,代码行数:13,代码来源:DynamicVariable.cs


示例5: HelpCommentsParser

 private HelpCommentsParser(CommandInfo commandInfo, List<string> parameterDescriptions)
 {
     this._sections = new CommentHelpInfo();
     this._parameters = new Dictionary<string, string>();
     this._examples = new List<string>();
     this._inputs = new List<string>();
     this._outputs = new List<string>();
     this._links = new List<string>();
     FunctionInfo info = commandInfo as FunctionInfo;
     if (info != null)
     {
         this.scriptBlock = info.ScriptBlock;
         this.commandName = info.Name;
     }
     else
     {
         ExternalScriptInfo info2 = commandInfo as ExternalScriptInfo;
         if (info2 != null)
         {
             this.scriptBlock = info2.ScriptBlock;
             this.commandName = info2.Path;
         }
     }
     this.commandMetadata = commandInfo.CommandMetadata;
     this.parameterDescriptions = parameterDescriptions;
 }
开发者ID:nickchal,项目名称:pash,代码行数:26,代码来源:HelpCommentsParser.cs


示例6: FunctionInfo

 internal FunctionInfo(string name, ScriptBlock function, ScopedItemOptions options)
     : base(name, CommandTypes.Function)
 {
     ScriptBlock = function;
     Options = options;
     ScopeUsage = ScopeUsages.NewScope;
 }
开发者ID:Ventero,项目名称:Pash,代码行数:7,代码来源:FunctionInfo.cs


示例7: FunctionInfo

 internal FunctionInfo(string verb, string noun, ScriptBlock function, IEnumerable<ParameterAst> explicitParams,
                       ScopedItemOptions options)
     : this(verb + "-" + noun, function, explicitParams, options)
 {
     Verb = verb;
     Noun = noun;
 }
开发者ID:mauve,项目名称:Pash,代码行数:7,代码来源:FunctionInfo.cs


示例8: Set

 public void Set(string name, ScriptBlock function, string description = "")
 {
     var qualName = new SessionStateScope<FunctionInfo>.QualifiedName(name);
     var info = new FunctionInfo(qualName.UnqualifiedName, function);
     info.Description = description;
     _scope.Set(name, info, true, true);
 }
开发者ID:prateek,项目名称:Pash,代码行数:7,代码来源:FunctionIntrinsics.cs


示例9: ScriptCommandProcessorBase

 protected ScriptCommandProcessorBase(ScriptBlock scriptBlock, ExecutionContext context, bool useLocalScope, CommandOrigin origin, SessionStateInternal sessionState)
 {
     this._dontUseScopeCommandOrigin = false;
     base.CommandInfo = new ScriptInfo(string.Empty, scriptBlock, context);
     base._fromScriptFile = false;
     this.CommonInitialization(scriptBlock, context, useLocalScope, sessionState);
     base.Command.CommandOriginInternal = origin;
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:ScriptCommandProcessorBase.cs


示例10: AsyncJob

 public AsyncJob(ScriptBlock Script, Hashtable Parameters)
     : this(Script)
 {
     foreach(DictionaryEntry param in Parameters)
     {
         this.Pipeline.AddParameter((string)param.Key, param.Value);
     }
 }
开发者ID:GoodOlClint,项目名称:PSAsync,代码行数:8,代码来源:AsyncJob.cs


示例11: Breakpoint

 internal Breakpoint(string script, ScriptBlock action)
 {
     Enabled = true;
     Script = script;
     Id = s_lastID++;
     Action = action;
     HitCount = 0;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:8,代码来源:Breakpoint.cs


示例12: MshExpression

 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="scriptBlock"></param>
 /// <exception cref="ArgumentNullException"></exception>
 internal MshExpression(ScriptBlock scriptBlock)
 {
     if (scriptBlock == null)
     {
         throw PSTraceSource.NewArgumentNullException("scriptBlock");
     }
     Script = scriptBlock;
 }
开发者ID:40a,项目名称:PowerShell,代码行数:13,代码来源:Mshexpression.cs


示例13: Breakpoint

 internal Breakpoint(string script, ScriptBlock action)
 {
     this.Enabled = true;
     this.Script = script;
     this.Id = _lastID++;
     this.Action = action;
     this.HitCount = 0;
 }
开发者ID:nickchal,项目名称:pash,代码行数:8,代码来源:Breakpoint.cs


示例14: LogFile

        public LogFile(string filename, StreamType streams = StreamType.All, ScriptBlock errorCallback = null)
        {
            fileName = System.IO.Path.GetFileName(filename);
            path = System.IO.Path.GetDirectoryName(filename);

            Streams = streams;
            ErrorCallback = errorCallback;
        }
开发者ID:dbeiler,项目名称:PowerShellLoggingModule,代码行数:8,代码来源:LogFile.cs


示例15: PowerShellProcessInstance

 public PowerShellProcessInstance(Version powerShellVersion, PSCredential credential, ScriptBlock initializationScript, bool useWow64)
 {
     this._syncObject = new object();
     string pSExePath = PSExePath;
     if (useWow64)
     {
         string environmentVariable = Environment.GetEnvironmentVariable("PROCESSOR_ARCHITECTURE");
         if (!string.IsNullOrEmpty(environmentVariable) && (environmentVariable.Equals("amd64", StringComparison.OrdinalIgnoreCase) || environmentVariable.Equals("ia64", StringComparison.OrdinalIgnoreCase)))
         {
             pSExePath = PSExePath.ToLowerInvariant().Replace(@"\system32\", @"\syswow64\");
             if (!System.IO.File.Exists(pSExePath))
             {
                 throw new PSInvalidOperationException(PSRemotingErrorInvariants.FormatResourceString(RemotingErrorIdStrings.IPCWowComponentNotPresent, new object[] { pSExePath }));
             }
         }
     }
     string str4 = string.Empty;
     Version version = powerShellVersion ?? PSVersionInfo.PSVersion;
     if (null == version)
     {
         version = new Version(3, 0);
     }
     str4 = string.Format(CultureInfo.InvariantCulture, "-Version {0}", new object[] { new Version(version.Major, version.Minor) });
     str4 = string.Format(CultureInfo.InvariantCulture, "{0} -s -NoLogo -NoProfile", new object[] { str4 });
     if (initializationScript != null)
     {
         string str5 = initializationScript.ToString();
         if (!string.IsNullOrEmpty(str5))
         {
             string str6 = Convert.ToBase64String(Encoding.Unicode.GetBytes(str5));
             str4 = string.Format(CultureInfo.InvariantCulture, "{0} -EncodedCommand {1}", new object[] { str4, str6 });
         }
     }
     ProcessStartInfo info = new ProcessStartInfo {
         FileName = useWow64 ? pSExePath : PSExePath,
         Arguments = str4,
         UseShellExecute = false,
         RedirectStandardInput = true,
         RedirectStandardOutput = true,
         RedirectStandardError = true,
         WindowStyle = ProcessWindowStyle.Hidden,
         CreateNoWindow = true,
         LoadUserProfile = true
     };
     this._startInfo = info;
     if (credential != null)
     {
         NetworkCredential networkCredential = credential.GetNetworkCredential();
         this._startInfo.UserName = networkCredential.UserName;
         this._startInfo.Domain = string.IsNullOrEmpty(networkCredential.Domain) ? "." : networkCredential.Domain;
         this._startInfo.Password = credential.Password;
     }
     System.Diagnostics.Process process = new System.Diagnostics.Process {
         StartInfo = this._startInfo,
         EnableRaisingEvents = true
     };
     this._process = process;
 }
开发者ID:nickchal,项目名称:pash,代码行数:58,代码来源:PowerShellProcessInstance.cs


示例16: ArgumentCompleterAttribute

        /// <summary>
        /// This constructor is used primarily via PowerShell scripts.
        /// </summary>
        /// <param name="scriptBlock"></param>
        public ArgumentCompleterAttribute(ScriptBlock scriptBlock)
        {
            if (scriptBlock == null)
            {
                throw PSTraceSource.NewArgumentNullException("scriptBlock");
            }

            ScriptBlock = scriptBlock;
        }
开发者ID:40a,项目名称:PowerShell,代码行数:13,代码来源:ExtensibleCompletion.cs


示例17: WorkflowInfo

 public WorkflowInfo(
     string name,
     string definition,
     ScriptBlock workflow,
     string xamlDefinition,
     WorkflowInfo[] workflowsCalled)
     : base(name, workflow, null)
 {
 }
开发者ID:mauve,项目名称:Pash,代码行数:9,代码来源:WorkflowInfo.cs


示例18: CreateWizard

 public static void CreateWizard(string name, ScriptBlock[] sb)
 {
     UIAutomation.Commands.NewUIAWizardCommand cmdlet =
         new UIAutomation.Commands.NewUIAWizardCommand();
     cmdlet.Name = name;
     cmdlet.StartAction = sb;
     UIANewWizardCommand command =
         new UIANewWizardCommand(cmdlet);
     command.Execute();
 }
开发者ID:uiatester,项目名称:STUPS,代码行数:10,代码来源:UnitTestingHelper.cs


示例19: ScriptInfo

        /// <summary>
        /// Creates an instance of the ScriptInfo class with the specified name, and script.
        /// </summary>
        /// 
        /// <param name="name">
        /// The name of the script.
        /// </param>
        /// 
        /// <param name="script">
        /// The script definition
        /// </param>
        /// 
        /// <param name="context">
        /// The execution context for the script.
        /// </param>
        /// 
        /// <exception cref="ArgumentNullException">
        /// If <paramref name="script"/> is null.
        /// </exception>
        /// 
        internal ScriptInfo(string name, ScriptBlock script, ExecutionContext context)
            : base(name, CommandTypes.Script, context)
        {
            if (script == null)
            {
                throw PSTraceSource.NewArgumentException("script");
            }

            this.ScriptBlock = script;
        } // ScriptInfo ctor
开发者ID:40a,项目名称:PowerShell,代码行数:30,代码来源:ScriptInfo.cs


示例20: BeginInvoke

 public void BeginInvoke(ScriptBlock scriptblock, PSObject inputObject)
 {
     _percentComplete = 0;
     string command = $"param($_,$PSItem, $PSPArallelIndex,$PSParallelProgressId){scriptblock}";
     _powerShell.AddScript(command)
         .AddParameter("_", inputObject)
         .AddParameter("PSItem", inputObject)
         .AddParameter("PSParallelIndex", _index)
         .AddParameter("PSParallelProgressId", _index + 1000);
     _powerShell.BeginInvoke(_input, _output);
 }
开发者ID:powercode,项目名称:PSParallel,代码行数:11,代码来源:PowerShellPoolMember.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Automation.SessionState类代码示例发布时间:2022-05-26
下一篇:
C# Automation.RuntimeDefinedParameter类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap