internal PSEventSubscriber( ExecutionContext context, int id, object source, string eventName, string sourceIdentifier, ScriptBlock action, bool supportEvent, bool forwardEvent) : this(context, id, source, eventName, sourceIdentifier, supportEvent, forwardEvent) { if (action == null) { return; } ScriptBlock boundScriptBlock = context.Modules.CreateBoundScriptBlock(action, true); PSVariable psVariable = new PSVariable("script:Error", (object)new ArrayList(), ScopedItemOptions.Constant); SessionStateInternal sessionStateInternal = boundScriptBlock.SessionStateInternal; sessionStateInternal.GetScopeByID("script").SetVariable(psVariable.Name, (object)psVariable, false, true, sessionStateInternal, CommandOrigin.Internal); this.action = new PSEventJob((PSEventManager)context.Events, this, boundScriptBlock, sourceIdentifier); if (supportEvent) { return; } ((LocalRunspace)context.CurrentRunspace).JobRepository.Add((Job)this.action); }
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); } }