/// <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);
        }
Example #2
0
        protected override object GetSourceObject()
        {
            CimIndicationWatcher cimIndicationWatcher = null;
            string parameterSet = null;

            try
            {
                parameterSet = this.parameterBinder.GetParameterSet();
            }
            finally
            {
                this.parameterBinder.reset();
            }
            string empty = string.Empty;
            string str   = parameterSet;
            string str1  = str;

            if (str != null)
            {
                if (str1 == "QueryExpressionSessionSet" || str1 == "QueryExpressionComputerSet")
                {
                    empty = this.Query;
                }
                else
                {
                    if (str1 == "ClassNameSessionSet" || str1 == "ClassNameComputerSet")
                    {
                        this.CheckArgument();
                        object[] className = new object[1];
                        className[0] = this.ClassName;
                        empty        = string.Format(CultureInfo.CurrentCulture, "Select * from {0}", className);
                    }
                }
            }
            string str2 = parameterSet;
            string str3 = str2;

            if (str2 != null)
            {
                if (str3 == "QueryExpressionSessionSet" || str3 == "ClassNameSessionSet")
                {
                    cimIndicationWatcher = new CimIndicationWatcher(this.CimSession, this.Namespace, this.QueryDialect, empty, this.OperationTimeoutSec);
                }
                else
                {
                    if (str3 == "QueryExpressionComputerSet" || str3 == "ClassNameComputerSet")
                    {
                        cimIndicationWatcher = new CimIndicationWatcher(this.ComputerName, this.Namespace, this.QueryDialect, empty, this.OperationTimeoutSec);
                    }
                }
            }
            if (cimIndicationWatcher != null)
            {
                cimIndicationWatcher.SetCmdlet(this);
            }
            return(cimIndicationWatcher);
        }
Example #3
0
        private static void newSubscriber_Unsubscribed(object sender, PSEventUnsubscribedEventArgs e)
        {
            DebugHelper.WriteLogEx();
            CimIndicationWatcher cimIndicationWatcher = sender as CimIndicationWatcher;

            if (cimIndicationWatcher != null)
            {
                cimIndicationWatcher.Stop();
            }
        }
 /// <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;
 }
		protected override object GetSourceObject()
		{
			CimIndicationWatcher cimIndicationWatcher = null;
			string parameterSet = null;
			try
			{
				parameterSet = this.parameterBinder.GetParameterSet();
			}
			finally
			{
				this.parameterBinder.reset();
			}
			string empty = string.Empty;
			string str = parameterSet;
			string str1 = str;
			if (str != null)
			{
				if (str1 == "QueryExpressionSessionSet" || str1 == "QueryExpressionComputerSet")
				{
					empty = this.Query;
				}
				else
				{
					if (str1 == "ClassNameSessionSet" || str1 == "ClassNameComputerSet")
					{
						this.CheckArgument();
						object[] className = new object[1];
						className[0] = this.ClassName;
						empty = string.Format(CultureInfo.CurrentCulture, "Select * from {0}", className);
					}
				}
			}
			string str2 = parameterSet;
			string str3 = str2;
			if (str2 != null)
			{
				if (str3 == "QueryExpressionSessionSet" || str3 == "ClassNameSessionSet")
				{
					cimIndicationWatcher = new CimIndicationWatcher(this.CimSession, this.Namespace, this.QueryDialect, empty, this.OperationTimeoutSec);
				}
				else
				{
					if (str3 == "QueryExpressionComputerSet" || str3 == "ClassNameComputerSet")
					{
						cimIndicationWatcher = new CimIndicationWatcher(this.ComputerName, this.Namespace, this.QueryDialect, empty, this.OperationTimeoutSec);
					}
				}
			}
			if (cimIndicationWatcher != null)
			{
				cimIndicationWatcher.SetCmdlet(this);
			}
			return cimIndicationWatcher;
		}