internal static bool MoveNext(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, IEnumerator enumerator) { bool flag; try { if ((context != null) && context.CurrentPipelineStopping) { throw new PipelineStoppedException(); } flag = enumerator.MoveNext(); } catch (RuntimeException) { throw; } catch (FlowControlException) { throw; } catch (ScriptCallDepthException) { throw; } catch (Exception exception) { CommandProcessorBase.CheckForSevereException(exception); throw InterpreterError.NewInterpreterExceptionWithInnerException(enumerator, typeof(RuntimeException), errorPosition, "BadEnumeration", ParserStrings.BadEnumeration, exception, new object[] { exception.Message }); } return(flag); }
internal AliasInfo SetAliasValue(string name, string value, System.Management.Automation.ExecutionContext context, bool force, CommandOrigin origin) { if (!this.GetAliases().ContainsKey(name)) { if (this.GetAliases().Count > (this.AliasCapacity.FastValue - 1)) { SessionStateOverflowException exception = new SessionStateOverflowException(name, SessionStateCategory.Alias, "AliasOverflow", SessionStateStrings.AliasOverflow, new object[] { this.AliasCapacity.FastValue }); throw exception; } this.GetAliases()[name] = new AliasInfo(name, value, context); } else { AliasInfo valueToCheck = this.GetAliases()[name]; if (((valueToCheck.Options & ScopedItemOptions.Constant) != ScopedItemOptions.None) || (!force && ((valueToCheck.Options & ScopedItemOptions.ReadOnly) != ScopedItemOptions.None))) { SessionStateUnauthorizedAccessException exception2 = new SessionStateUnauthorizedAccessException(name, SessionStateCategory.Alias, "AliasNotWritable", SessionStateStrings.AliasNotWritable); throw exception2; } SessionState.ThrowIfNotVisible(origin, valueToCheck); this.RemoveAliasFromCache(valueToCheck.Name, valueToCheck.Definition); if (force) { this.GetAliases().Remove(name); valueToCheck = new AliasInfo(name, value, context); this.GetAliases()[name] = valueToCheck; } else { valueToCheck.SetDefinition(value, false); } } this.AddAliasToCache(name, value); return(this.GetAliases()[name]); }
internal static void LogProviderHealthEvent(System.Management.Automation.ExecutionContext executionContext, string providerName, Exception exception, Severity severity) { if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else if (exception == null) { PSTraceSource.NewArgumentNullException("exception"); } else { InvocationInfo invocationInfo = null; IContainsErrorRecord record = exception as IContainsErrorRecord; if ((record != null) && (record.ErrorRecord != null)) { invocationInfo = record.ErrorRecord.InvocationInfo; } foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogProviderHealthEvent(provider, executionContext)) { provider.LogProviderHealthEvent(GetLogContext(executionContext, invocationInfo, severity), providerName, exception); } } } }
internal static void LogCommandLifecycleEvent(System.Management.Automation.ExecutionContext executionContext, CommandState commandState, InvocationInfo invocationInfo) { Func <LogContext> getLogContext = null; LogContext logContext; if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else if (invocationInfo == null) { PSTraceSource.NewArgumentNullException("invocationInfo"); } else if (!ignoredCommands.Contains(invocationInfo.MyCommand.Name)) { logContext = null; foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogCommandLifecycleEvent(provider, executionContext)) { if (getLogContext == null) { getLogContext = () => logContext ?? (logContext = GetLogContext(executionContext, invocationInfo)); } provider.LogCommandLifecycleEvent(getLogContext, commandState); } } } }
internal static void LogEngineHealthEvent(System.Management.Automation.ExecutionContext executionContext, int eventId, Exception exception, Severity severity, Dictionary <string, string> additionalInfo, EngineState newEngineState) { if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else if (exception == null) { PSTraceSource.NewArgumentNullException("exception"); } else { InvocationInfo invocationInfo = null; IContainsErrorRecord record = exception as IContainsErrorRecord; if ((record != null) && (record.ErrorRecord != null)) { invocationInfo = record.ErrorRecord.InvocationInfo; } foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogEngineHealthEvent(provider, executionContext)) { provider.LogEngineHealthEvent(GetLogContext(executionContext, invocationInfo, severity), eventId, exception, additionalInfo); } } if (newEngineState != EngineState.None) { LogEngineLifecycleEvent(executionContext, newEngineState, invocationInfo); } } }
internal CmdletProviderContext(PSCmdlet command, PSCredential credentials, PSDriveInfo drive) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection <PSObject>(); this.accumulatedErrorObjects = new Collection <ErrorRecord>(); this.stopReferrals = new Collection <CmdletProviderContext>(); if (command == null) { throw PSTraceSource.NewArgumentNullException("command"); } this.command = command; this._origin = command.CommandOrigin; if (credentials != null) { this.credentials = credentials; } this.drive = drive; if (command.Host == null) { throw PSTraceSource.NewArgumentException("command.Host"); } if (command.Context == null) { throw PSTraceSource.NewArgumentException("command.Context"); } this.executionContext = command.Context; this.streamObjects = true; this.streamErrors = true; }
private static object SplitWithPattern(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, IEnumerable <string> content, string separatorPattern, int limit, SplitOptions options) { if (((options & SplitOptions.SimpleMatch) == 0) && ((options & SplitOptions.RegexMatch) == 0)) { options |= SplitOptions.RegexMatch; } if (((options & SplitOptions.SimpleMatch) != 0) && ((options & ~(SplitOptions.IgnoreCase | SplitOptions.SimpleMatch)) != 0)) { throw InterpreterError.NewInterpreterException(null, typeof(ParseException), errorPosition, "InvalidSplitOptionCombination", ParserStrings.InvalidSplitOptionCombination, new object[0]); } if ((options & (SplitOptions.Singleline | SplitOptions.Multiline)) == (SplitOptions.Singleline | SplitOptions.Multiline)) { throw InterpreterError.NewInterpreterException(null, typeof(ParseException), errorPosition, "InvalidSplitOptionCombination", ParserStrings.InvalidSplitOptionCombination, new object[0]); } if ((options & SplitOptions.SimpleMatch) != 0) { separatorPattern = Regex.Escape(separatorPattern); } if (limit < 0) { limit = 0; } RegexOptions options2 = parseRegexOptions(options); Regex regex = NewRegex(separatorPattern, options2); List <string> list = new List <string>(); foreach (string str in content) { string[] items = regex.Split(str, limit, 0); ExtendList <string>(list, items); } return(list.ToArray()); }
internal CmdletProviderContext(CmdletProviderContext contextToCopyFrom) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection<PSObject>(); this.accumulatedErrorObjects = new Collection<ErrorRecord>(); this.stopReferrals = new Collection<CmdletProviderContext>(); if (contextToCopyFrom == null) { throw PSTraceSource.NewArgumentNullException("contextToCopyFrom"); } this.executionContext = contextToCopyFrom.ExecutionContext; this.command = contextToCopyFrom.command; if (contextToCopyFrom.Credential != null) { this.credentials = contextToCopyFrom.Credential; } this.drive = contextToCopyFrom.Drive; this.force = (bool) contextToCopyFrom.Force; this.CopyFilters(contextToCopyFrom); this.suppressWildcardExpansion = contextToCopyFrom.SuppressWildcardExpansion; this.dynamicParameters = contextToCopyFrom.DynamicParameters; this._origin = contextToCopyFrom._origin; this.stopping = contextToCopyFrom.Stopping; contextToCopyFrom.StopReferrals.Add(this); this.copiedContext = contextToCopyFrom; }
internal CmdletProviderContext(CmdletProviderContext contextToCopyFrom) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection <PSObject>(); this.accumulatedErrorObjects = new Collection <ErrorRecord>(); this.stopReferrals = new Collection <CmdletProviderContext>(); if (contextToCopyFrom == null) { throw PSTraceSource.NewArgumentNullException("contextToCopyFrom"); } this.executionContext = contextToCopyFrom.ExecutionContext; this.command = contextToCopyFrom.command; if (contextToCopyFrom.Credential != null) { this.credentials = contextToCopyFrom.Credential; } this.drive = contextToCopyFrom.Drive; this.force = (bool)contextToCopyFrom.Force; this.CopyFilters(contextToCopyFrom); this.suppressWildcardExpansion = contextToCopyFrom.SuppressWildcardExpansion; this.dynamicParameters = contextToCopyFrom.DynamicParameters; this._origin = contextToCopyFrom._origin; this.stopping = contextToCopyFrom.Stopping; contextToCopyFrom.StopReferrals.Add(this); this.copiedContext = contextToCopyFrom; }
internal static void LogCommandLifecycleEvent(System.Management.Automation.ExecutionContext executionContext, CommandState commandState, string commandName) { Func <LogContext> getLogContext = null; LogContext logContext; if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else { logContext = null; foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogCommandLifecycleEvent(provider, executionContext)) { if (getLogContext == null) { getLogContext = delegate { if (logContext == null) { logContext = GetLogContext(executionContext, null); logContext.CommandName = commandName; } return(logContext); }; } provider.LogCommandLifecycleEvent(getLogContext, commandState); } } } }
private static IEnumerable <LogProvider> GetLogProvider(System.Management.Automation.ExecutionContext executionContext) { if (executionContext == null) { throw PSTraceSource.NewArgumentNullException("executionContext"); } return(GetLogProvider(executionContext.ShellID)); }
internal void SetAutomaticVariable(AutomaticVariable auto, object value, System.Management.Automation.ExecutionContext context) { if (context._debuggingMode > 0) { context.Debugger.CheckVariableWrite(SpecialVariables.AutomaticVariables[(int)auto]); } this.SetValue((int)auto, value); }
internal PSEventSubscriber(System.Management.Automation.ExecutionContext context, int id, object source, string eventName, string sourceIdentifier, ScriptBlock action, bool supportEvent, bool forwardEvent, int maxTriggerCount) : this(context, id, source, eventName, sourceIdentifier, supportEvent, forwardEvent, maxTriggerCount) { if (action != null) { ScriptBlock block = this.CreateBoundScriptBlock(action); this.action = new PSEventJob(context.Events, this, block, sourceIdentifier); } }
internal CommandInvocationIntrinsics(System.Management.Automation.ExecutionContext context, PSCmdlet cmdlet) { this._context = context; if (cmdlet != null) { this._cmdlet = cmdlet; this.commandRuntime = cmdlet.CommandRuntime as MshCommandRuntime; } }
internal MshCommandRuntime(System.Management.Automation.ExecutionContext context, CommandInfo commandInfo, InternalCommand thisCommand) { this.context = context; this.host = context.EngineHostInterface; this.CBhost = context.EngineHostInterface; this.commandInfo = commandInfo; this.thisCommand = thisCommand; this.shouldLogPipelineExecutionDetail = this.InitShouldLogPipelineExecutionDetail(); }
internal ParameterBinderBase(System.Management.Automation.InvocationInfo invocationInfo, System.Management.Automation.ExecutionContext context, InternalCommand command) { this.RecordBoundParameters = true; bindingTracer.ShowHeaders = false; this.command = command; this.invocationInfo = invocationInfo; this.context = context; this.engine = context.EngineIntrinsics; }
internal HelpSystem(System.Management.Automation.ExecutionContext context) { if (context == null) { throw PSTraceSource.NewArgumentNullException("ExecutionContext"); } this._executionContext = context; this.Initialize(); }
internal ExternalScriptInfo(string name, string path, System.Management.Automation.ExecutionContext context) : base(name, CommandTypes.ExternalScript, context) { this._path = string.Empty; if (string.IsNullOrEmpty(path)) { throw PSTraceSource.NewArgumentException("path"); } this._path = System.IO.Path.GetFullPath(path); this.CommonInitialization(); }
internal static void CheckForInterrupts(System.Management.Automation.ExecutionContext context) { if (context.Events != null) { context.Events.ProcessPendingActions(); } if (context.CurrentPipelineStopping) { throw new PipelineStoppedException(); } }
internal static object JoinOperator(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, object lval, object rval) { string separator = PSObject.ToStringParser(context, rval); IEnumerable enumerable = LanguagePrimitives.GetEnumerable(lval); if (enumerable != null) { return(PSObject.ToStringEnumerable(context, enumerable, separator, null, null)); } return(PSObject.ToStringParser(context, lval)); }
internal Debugger(System.Management.Automation.ExecutionContext context) { this._context = context; this.InBreakpoint = false; this._idToBreakpoint = new Dictionary<int, Breakpoint>(); this._pendingBreakpoints = new List<LineBreakpoint>(); this._boundBreakpoints = new Dictionary<string, Tuple<WeakReference, List<LineBreakpoint>>>(StringComparer.OrdinalIgnoreCase); this._commandBreakpoints = new List<CommandBreakpoint>(); this._variableBreakpoints = new Dictionary<string, List<VariableBreakpoint>>(StringComparer.OrdinalIgnoreCase); this._steppingMode = SteppingMode.None; this._callStack = new List<CallStackInfo>(); }
internal static SteppablePipeline GetSteppablePipeline(PipelineAst pipelineAst, CommandOrigin commandOrigin) { PipelineProcessor pipe = new PipelineProcessor(); System.Management.Automation.ExecutionContext executionContextFromTLS = LocalPipeline.GetExecutionContextFromTLS(); foreach (CommandAst ast in pipelineAst.PipelineElements.Cast <CommandAst>()) { List <CommandParameterInternal> list = new List <CommandParameterInternal>(); foreach (CommandElementAst ast2 in ast.CommandElements) { CommandParameterAst commandParameterAst = ast2 as CommandParameterAst; if (commandParameterAst != null) { list.Add(GetCommandParameter(commandParameterAst, executionContextFromTLS)); } else { ExpressionAst expressionAst = (ExpressionAst)ast2; object obj2 = Compiler.GetExpressionValue(expressionAst, executionContextFromTLS, (IList)null); bool splatted = (expressionAst is VariableExpressionAst) && ((VariableExpressionAst)expressionAst).Splatted; list.Add(CommandParameterInternal.CreateArgument(expressionAst.Extent, obj2, splatted)); } } List <CommandRedirection> list2 = new List <CommandRedirection>(); foreach (RedirectionAst ast5 in ast.Redirections) { list2.Add(GetCommandRedirection(ast5, executionContextFromTLS)); } CommandProcessorBase base2 = AddCommand(pipe, list.ToArray(), ast, list2.ToArray(), executionContextFromTLS); base2.Command.CommandOriginInternal = commandOrigin; base2.CommandScope.ScopeOrigin = commandOrigin; base2.Command.MyInvocation.CommandOrigin = commandOrigin; CallStackFrame[] frameArray = executionContextFromTLS.Debugger.GetCallStack().ToArray <CallStackFrame>(); if ((frameArray.Length > 0) && Regex.IsMatch(frameArray[0].Position.Text, "GetSteppablePipeline", RegexOptions.IgnoreCase)) { InvocationInfo myInvocation = base2.Command.MyInvocation; myInvocation.InvocationName = frameArray[0].InvocationInfo.InvocationName; if (frameArray.Length > 1) { IScriptExtent position = frameArray[1].Position; if ((position != null) && (position != PositionUtilities.EmptyExtent)) { myInvocation.DisplayScriptPosition = position; } } } if ((executionContextFromTLS.CurrentCommandProcessor != null) && (executionContextFromTLS.CurrentCommandProcessor.CommandRuntime != null)) { base2.CommandRuntime.SetMergeFromRuntime(executionContextFromTLS.CurrentCommandProcessor.CommandRuntime); } } return(new SteppablePipeline(executionContextFromTLS, pipe)); }
internal Debugger(System.Management.Automation.ExecutionContext context) { this._context = context; this.InBreakpoint = false; this._idToBreakpoint = new Dictionary <int, Breakpoint>(); this._pendingBreakpoints = new List <LineBreakpoint>(); this._boundBreakpoints = new Dictionary <string, Tuple <WeakReference, List <LineBreakpoint> > >(StringComparer.OrdinalIgnoreCase); this._commandBreakpoints = new List <CommandBreakpoint>(); this._variableBreakpoints = new Dictionary <string, List <VariableBreakpoint> >(StringComparer.OrdinalIgnoreCase); this._steppingMode = SteppingMode.None; this._callStack = new List <CallStackInfo>(); }
public void ValidateScriptInfo(PSHost host) { if (!this._signatureChecked) { System.Management.Automation.ExecutionContext context = base.Context ?? LocalPipeline.GetExecutionContextFromTLS(); this.ReadScriptContents(); if (context != null) { CommandDiscovery.ShouldRun(context, host, this, CommandOrigin.Internal); this._signatureChecked = true; } } }
private static object SplitOperatorImpl(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, object lval, object rval, SplitImplOptions implOptions, bool ignoreCase) { IEnumerable <string> content = enumerateContent(context, errorPosition, implOptions, lval); ScriptBlock predicate = null; string separatorPattern = null; int limit = 0; SplitOptions options = 0; object[] objArray = unfoldTuple(context, errorPosition, rval); if (objArray.Length < 1) { throw InterpreterError.NewInterpreterException(rval, typeof(RuntimeException), errorPosition, "BadOperatorArgument", ParserStrings.BadOperatorArgument, new object[] { "-split", rval }); } object obj1 = objArray[0]; predicate = objArray[0] as ScriptBlock; if (predicate == null) { separatorPattern = PSObject.ToStringParser(context, objArray[0]); } if (objArray.Length >= 2) { limit = FixNum(objArray[1], errorPosition); } if ((objArray.Length >= 3) && (objArray[2] != null)) { string str2 = objArray[2] as string; if ((str2 == null) || !string.IsNullOrEmpty(str2)) { options = ConvertTo <SplitOptions>(objArray[2], errorPosition); if (predicate != null) { throw InterpreterError.NewInterpreterException(null, typeof(ParseException), errorPosition, "InvalidSplitOptionWithPredicate", ParserStrings.InvalidSplitOptionWithPredicate, new object[0]); } if (ignoreCase && ((options & SplitOptions.IgnoreCase) == 0)) { options |= SplitOptions.IgnoreCase; } } } else if (ignoreCase) { options |= SplitOptions.IgnoreCase; } if (predicate != null) { return(SplitWithPredicate(context, errorPosition, content, predicate, limit)); } return(SplitWithPattern(context, errorPosition, content, separatorPattern, limit, options)); }
internal CmdletProviderContext(System.Management.Automation.ExecutionContext executionContext, CommandOrigin origin) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection <PSObject>(); this.accumulatedErrorObjects = new Collection <ErrorRecord>(); this.stopReferrals = new Collection <CmdletProviderContext>(); if (executionContext == null) { throw PSTraceSource.NewArgumentNullException("executionContext"); } this.executionContext = executionContext; this._origin = origin; }
internal static void InvokePipeline(object input, bool ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext) { PipelineProcessor pipelineProcessor = new PipelineProcessor(); System.Management.Automation.ExecutionContext context = funcContext._executionContext; Pipe pipe = funcContext._outputPipe; try { if (context.Events != null) { context.Events.ProcessPendingActions(); } if ((input == AutomationNull.Value) && !ignoreInput) { AddNoopCommandProcessor(pipelineProcessor, context); } CommandProcessorBase commandProcessor = null; CommandRedirection[] redirections = null; for (int i = 0; i < pipeElements.Length; i++) { redirections = (commandRedirections != null) ? commandRedirections [i] : null; commandProcessor = AddCommand(pipelineProcessor, pipeElements [i], pipeElementAsts [i], redirections, context); } if ((commandProcessor != null) && !commandProcessor.CommandRuntime.OutputPipe.IsRedirected) { pipelineProcessor.LinkPipelineSuccessOutput(pipe ?? new Pipe(new ArrayList())); if (redirections != null) { foreach (CommandRedirection redirection in redirections) { if (redirection is MergingRedirection) { redirection.Bind(pipelineProcessor, commandProcessor, context); } } } } context.PushPipelineProcessor(pipelineProcessor); try { pipelineProcessor.SynchronousExecuteEnumerate(input, null, true); } finally { context.PopPipelineProcessor(false); } } finally { context.QuestionMarkVariableValue = !pipelineProcessor.ExecutionFailed; pipelineProcessor.Dispose(); } }
private static object SplitWithPredicate(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, IEnumerable <string> content, ScriptBlock predicate, int limit) { List <string> list = new List <string>(); foreach (string str in content) { List <string> items = new List <string>(); if (limit == 1) { list.Add(str); continue; } StringBuilder builder = new StringBuilder(); for (int i = 0; i < str.Length; i++) { if (LanguagePrimitives.IsTrue(predicate.DoInvokeReturnAsIs(true, ScriptBlock.ErrorHandlingBehavior.WriteToExternalErrorPipe, CharToString(str[i]), AutomationNull.Value, AutomationNull.Value, new object[] { str, i }))) { items.Add(builder.ToString()); builder = new StringBuilder(); if ((limit > 0) && (items.Count >= (limit - 1))) { if ((i + 1) < str.Length) { items.Add(str.Substring(i + 1)); } else { items.Add(""); } break; } if (i == (str.Length - 1)) { items.Add(""); } } else { builder.Append(str[i]); } } if ((builder.Length > 0) && ((limit <= 0) || (items.Count < limit))) { items.Add(builder.ToString()); } ExtendList <string>(list, items); } return(list.ToArray()); }
internal static void CacheExportedCommands(PSModuleInfo module, bool force, System.Management.Automation.ExecutionContext context) { string basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), @"Microsoft\Windows\PowerShell\CommandAnalysis\"); ModuleIntrinsics.Tracer.WriteLine("Requested caching for " + module.Name + " at " + basePath, new object[0]); if (!force) { Dictionary <string, List <CommandTypes> > dictionary = GetExportedCommands(module.Path, true, context); if (((dictionary != null) && (module.ExportedCommands != null)) && (dictionary.Count == module.ExportedCommands.Count)) { ModuleIntrinsics.Tracer.WriteLine("Existing cached info up-to-date. Skipping.", new object[0]); return; } } ModuleIntrinsics.Tracer.WriteLine("Obtaining mutex PowerShell_CommandAnalysis_Lock for caching.", new object[0]); using (Mutex mutex = new Mutex(false, "PowerShell_CommandAnalysis_Lock")) { mutex.WaitOne(); try { Dictionary <string, List <CommandTypes> > dictionary2 = new Dictionary <string, List <CommandTypes> >(StringComparer.OrdinalIgnoreCase); if (module.ExportedCommands != null) { ModuleIntrinsics.Tracer.WriteLine("Caching " + module.ExportedCommands.Count + " commands", new object[0]); foreach (CommandInfo info in module.ExportedCommands.Values) { if (!dictionary2.ContainsKey(info.Name)) { ModuleIntrinsics.Tracer.WriteLine("Caching " + info.Name, new object[0]); dictionary2[info.Name] = new List <CommandTypes>(); } dictionary2[info.Name].Add(info.CommandType); } Cache <Dictionary <string, List <CommandTypes> > >(basePath, module.Path, dictionary2); lock (itemCache) { itemCache[module.Path] = dictionary2; } } } finally { ModuleIntrinsics.Tracer.WriteLine("Releasing mutex after caching.", new object[0]); mutex.ReleaseMutex(); } } }
internal static void LogProviderLifecycleEvent(System.Management.Automation.ExecutionContext executionContext, string providerName, ProviderState providerState) { if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else { foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogProviderLifecycleEvent(provider, executionContext)) { provider.LogProviderLifecycleEvent(GetLogContext(executionContext, null), providerName, providerState); } } } }
internal static void LogSettingsEvent(System.Management.Automation.ExecutionContext executionContext, string variableName, string newValue, string previousValue, InvocationInfo invocationInfo) { if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else { foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogSettingsEvent(provider, executionContext)) { provider.LogSettingsEvent(GetLogContext(executionContext, invocationInfo), variableName, newValue, previousValue); } } } }
internal static object ContainsOperator(System.Management.Automation.ExecutionContext context, IScriptExtent errorPosition, object left, object right, bool contains, bool ignoreCase) { IEnumerator enumerator = LanguagePrimitives.GetEnumerator(left); if (enumerator != null) { while (MoveNext(context, errorPosition, enumerator)) { if (LanguagePrimitives.Equals(Current(errorPosition, enumerator), right, ignoreCase, CultureInfo.InvariantCulture)) { return(BoolToObject(contains)); } } return(BoolToObject(!contains)); } return(BoolToObject(contains == LanguagePrimitives.Equals(left, right, ignoreCase, CultureInfo.InvariantCulture))); }
internal static void LogPipelineExecutionDetailEvent(System.Management.Automation.ExecutionContext executionContext, List <string> detail, InvocationInfo invocationInfo) { if (executionContext == null) { PSTraceSource.NewArgumentNullException("executionContext"); } else { foreach (LogProvider provider in GetLogProvider(executionContext)) { if (NeedToLogPipelineExecutionDetailEvent(provider, executionContext)) { provider.LogPipelineExecutionDetailEvent(GetLogContext(executionContext, invocationInfo), detail); } } } }
internal SessionStateInternal(SessionStateInternal parent, bool linkToGlobal, System.Management.Automation.ExecutionContext context) { this.ModuleTableKeys = new List<string>(); this._moduleTable = new Dictionary<string, PSModuleInfo>(StringComparer.OrdinalIgnoreCase); this._scripts = new List<string>(new string[] { "*" }); this._applications = new List<string>(new string[] { "*" }); this._exportedCmdlets = new List<CmdletInfo>(); this._exportedAliases = new List<AliasInfo>(); this._exportedFunctions = new List<FunctionInfo>(); this._exportedWorkflows = new List<WorkflowInfo>(); this.defaultStackName = "default"; this._providers = new Dictionary<string, List<ProviderInfo>>(100, StringComparer.OrdinalIgnoreCase); this._providersCurrentWorkingDrive = new Dictionary<ProviderInfo, PSDriveInfo>(); this._exportedVariables = new List<PSVariable>(); if (context == null) { throw PSTraceSource.NewArgumentNullException("context"); } this._context = context; this.workingLocationStack = new Dictionary<string, Stack<PathInfo>>(StringComparer.OrdinalIgnoreCase); this._globalScope = new SessionStateScope(null); this._moduleScope = this._globalScope; this.currentScope = this._globalScope; this.InitializeSessionStateInternalSpecialVariables(false); this._globalScope.ScriptScope = this._globalScope; if (parent != null) { this._globalScope.Parent = parent.GlobalScope; this.CopyProviders(parent); if ((this.Providers != null) && (this.Providers.Count > 0)) { this.CurrentDrive = parent.CurrentDrive; } if (linkToGlobal) { this._globalScope = parent.GlobalScope; } } else { this.currentScope.LocalsTuple = MutableTuple.MakeTuple(Compiler.DottedLocalsTupleType, Compiler.DottedLocalsNameIndexMap); } }
internal CmdletProviderContext(Cmdlet command) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection<PSObject>(); this.accumulatedErrorObjects = new Collection<ErrorRecord>(); this.stopReferrals = new Collection<CmdletProviderContext>(); if (command == null) { throw PSTraceSource.NewArgumentNullException("command"); } this.command = command; this._origin = command.CommandOrigin; if (command.Context == null) { throw PSTraceSource.NewArgumentException("command.Context"); } this.executionContext = command.Context; this.streamObjects = true; this.streamErrors = true; }
internal PSLocalEventManager(System.Management.Automation.ExecutionContext context) { this.context = context; }
internal CmdletProviderContext(System.Management.Automation.ExecutionContext executionContext, CommandOrigin origin) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection<PSObject>(); this.accumulatedErrorObjects = new Collection<ErrorRecord>(); this.stopReferrals = new Collection<CmdletProviderContext>(); if (executionContext == null) { throw PSTraceSource.NewArgumentNullException("executionContext"); } this.executionContext = executionContext; this._origin = origin; }
internal CmdletProviderContext(System.Management.Automation.ExecutionContext executionContext) { this.credentials = PSCredential.Empty; this._origin = CommandOrigin.Internal; this.accumulatedObjects = new Collection<PSObject>(); this.accumulatedErrorObjects = new Collection<ErrorRecord>(); this.stopReferrals = new Collection<CmdletProviderContext>(); if (executionContext == null) { throw PSTraceSource.NewArgumentNullException("executionContext"); } this.executionContext = executionContext; this._origin = CommandOrigin.Internal; this.drive = executionContext.EngineSessionState.CurrentDrive; if ((executionContext.CurrentCommandProcessor != null) && (executionContext.CurrentCommandProcessor.Command is Cmdlet)) { this.command = (Cmdlet) executionContext.CurrentCommandProcessor.Command; } }
internal AliasHelpProvider(HelpSystem helpSystem) : base(helpSystem) { this._sessionState = helpSystem.ExecutionContext.SessionState; this._commandDiscovery = helpSystem.ExecutionContext.CommandDiscovery; this._context = helpSystem.ExecutionContext; }
internal CommandHelpProvider(HelpSystem helpSystem) : base(helpSystem) { this._helpFiles = new Hashtable(); this._context = helpSystem.ExecutionContext; }