예제 #1
0
        /// <summary>
        /// <para>
        /// Handle async event triggered by <see cref="CimResultObserver<T>"/>
        /// </para>
        /// </summary>
        /// <param name="observer">object triggered the event</param>
        /// <param name="resultArgs">async result event argument</param>
        internal void ResultEventHandler(
            object observer,
            AsyncResultEventArgsBase resultArgs)
        {
            DebugHelper.WriteLogEx();
            switch (resultArgs.resultType)
            {
                case AsyncResultType.Completion:
                    {
                        DebugHelper.WriteLog("ResultEventHandler::Completion", 4);

                        AsyncResultCompleteEventArgs args = resultArgs as AsyncResultCompleteEventArgs;
                        this.FireOperationDeletedEvent(args.observable, true);
                    }
                    break;
                case AsyncResultType.Exception:
                    {
                        AsyncResultErrorEventArgs args = resultArgs as AsyncResultErrorEventArgs;
                        DebugHelper.WriteLog("ResultEventHandler::Exception {0}", 4, args.error);

                        using (CimWriteError action = new CimWriteError(args.error, this.invocationContextObject, args.context))
                        {
                            this.FireNewActionEvent(action);
                        }
                        this.FireOperationDeletedEvent(args.observable, false);
                    }
                    break;
                case AsyncResultType.Result:
                    {
                        AsyncResultObjectEventArgs args = resultArgs as AsyncResultObjectEventArgs;
                        DebugHelper.WriteLog("ResultEventHandler::Result {0}", 4, args.resultObject);
                        object resultObject = args.resultObject;
                        if (!this.isDefaultSession)
                        {
                            AddShowComputerNameMarker(resultObject);
                        }
                        if (this.ObjectPreProcess != null)
                        {
                            resultObject = this.ObjectPreProcess.Process(resultObject);
                        }
#if DEBUG
                        resultObject = PostProcessCimInstance(resultObject);
#endif
                        CimWriteResultObject action = new CimWriteResultObject(resultObject, this.ContextObject);
                        this.FireNewActionEvent(action);
                    }
                    break;
                default:
                    break;
            }
        }
예제 #2
0
		internal void ResultEventHandler(object observer, AsyncResultEventArgsBase resultArgs)
		{
			DebugHelper.WriteLogEx();
			AsyncResultType asyncResultType = resultArgs.resultType;
			switch (asyncResultType)
			{
				case AsyncResultType.Result:
				{
					AsyncResultObjectEventArgs asyncResultObjectEventArg = resultArgs as AsyncResultObjectEventArgs;
					object[] objArray = new object[1];
					objArray[0] = asyncResultObjectEventArg.resultObject;
					DebugHelper.WriteLog("ResultEventHandler::Result {0}", 4, objArray);
					object obj = asyncResultObjectEventArg.resultObject;
					if (!this.isDefaultSession)
					{
						CimSessionProxy.AddShowComputerNameMarker(obj);
					}
					if (this.ObjectPreProcess != null)
					{
						obj = this.ObjectPreProcess.Process(obj);
					}
					CimWriteResultObject cimWriteResultObject = new CimWriteResultObject(obj, this.ContextObject);
					this.FireNewActionEvent(cimWriteResultObject);
					return;
				}
				case AsyncResultType.Exception:
				{
					AsyncResultErrorEventArgs asyncResultErrorEventArg = resultArgs as AsyncResultErrorEventArgs;
					object[] objArray1 = new object[1];
					objArray1[0] = asyncResultErrorEventArg.error;
					DebugHelper.WriteLog("ResultEventHandler::Exception {0}", 4, objArray1);
					using (CimWriteError cimWriteError = new CimWriteError(asyncResultErrorEventArg.error, this.invocationContextObject, asyncResultErrorEventArg.context))
					{
						this.FireNewActionEvent(cimWriteError);
					}
					this.FireOperationDeletedEvent(asyncResultErrorEventArg.observable, false);
					return;
				}
				case AsyncResultType.Completion:
				{
					DebugHelper.WriteLog("ResultEventHandler::Completion", 4);
					AsyncResultCompleteEventArgs asyncResultCompleteEventArg = resultArgs as AsyncResultCompleteEventArgs;
					this.FireOperationDeletedEvent(asyncResultCompleteEventArg.observable, true);
					return;
				}
				default:
				{
					return;
				}
			}
		}