/// <summary> /// Returns the object that generates events to be monitored. /// </summary> protected override object GetSourceObject() { CimIndicationWatcher watcher = null; string parameterSetName = null; try { parameterSetName = this.parameterBinder.GetParameterSet(); } finally { this.parameterBinder.reset(); } string tempQueryExpression = string.Empty; switch (parameterSetName) { case CimBaseCommand.QueryExpressionSessionSet: case CimBaseCommand.QueryExpressionComputerSet: tempQueryExpression = this.Query; break; case CimBaseCommand.ClassNameSessionSet: case CimBaseCommand.ClassNameComputerSet: // validate the classname this.CheckArgument(); tempQueryExpression = string.Format(CultureInfo.CurrentCulture, "Select * from {0}", this.ClassName); break; } switch (parameterSetName) { case CimBaseCommand.QueryExpressionSessionSet: case CimBaseCommand.ClassNameSessionSet: { watcher = new CimIndicationWatcher(this.CimSession, this.Namespace, this.QueryDialect, tempQueryExpression, this.OperationTimeoutSec); } break; case CimBaseCommand.QueryExpressionComputerSet: case CimBaseCommand.ClassNameComputerSet: { watcher = new CimIndicationWatcher(this.ComputerName, this.Namespace, this.QueryDialect, tempQueryExpression, this.OperationTimeoutSec); } break; } if (watcher != null) { watcher.SetCmdlet(this); } return(watcher); }
/// <summary> /// <para> /// Handler to handle unsubscribe event /// </para> /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private static void newSubscriber_Unsubscribed( object sender, PSEventUnsubscribedEventArgs e) { DebugHelper.WriteLogEx(); CimIndicationWatcher watcher = sender as CimIndicationWatcher; if (watcher != null) { watcher.Stop(); } }