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


C# Automation.ScriptBlock类代码示例

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


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


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