protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (args.Action as CimWriteResultObject != null) { CimWriteResultObject action = args.Action as CimWriteResultObject; CimInstance result = action.Result as CimInstance; if (result != null) { object[] className = new object[2]; className[0] = result.CimSystemProperties.ClassName; className[1] = result.CimSystemProperties.Namespace; DebugHelper.WriteLog("Going to read CimInstance classname = {0}; namespace = {1}", 1, className); this.NewCimInstanceOperation.GetCimInstance(result, base.ContextObject); return(false); } else { return(true); } } else { return(true); } }
protected void NewCmdletActionHandler(object cimSession, CmdletActionEventArgs actionArgs) { object[] action = new object[2]; action[0] = this._disposed; action[1] = actionArgs.Action; DebugHelper.WriteLogEx("Disposed {0}, action type = {1}", 0, action); if (!this.Disposed) { bool isEmpty = this.actionQueue.IsEmpty; this.actionQueue.Enqueue(actionArgs.Action); if (isEmpty) { this.moreActionEvent.Set(); } return; } else { if (actionArgs.Action as CimSyncAction != null) { (actionArgs.Action as CimSyncAction).OnComplete(); } return; } }
protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (args.Action as CimWriteResultObject != null) { CimWriteResultObject action = args.Action as CimWriteResultObject; CimInstance result = action.Result as CimInstance; if (result != null) { object[] className = new object[2]; className[0] = result.CimSystemProperties.ClassName; className[1] = result.CimSystemProperties.Namespace; DebugHelper.WriteLog("Going to read CimInstance classname = {0}; namespace = {1}", 1, className); this.NewCimInstanceOperation.GetCimInstance(result, base.ContextObject); return false; } else { return true; } } else { return true; } }
protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (this.passThru || args.Action as CimWriteResultObject == null) { return true; } else { return false; } }
protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (this.passThru || args.Action as CimWriteResultObject == null) { return(true); } else { return(false); } }
/// <summary> /// <para> /// Handler used to handle new action event from /// <seealso cref="CimSessionProxy"/> object. /// </para> /// </summary> /// <param name="cimSession"> /// <seealso cref="CimSession"/> object raised the event /// </param> /// <param name="actionArgs">event argument</param> protected void NewCmdletActionHandler(object cimSession, CmdletActionEventArgs actionArgs) { DebugHelper.WriteLogEx("Disposed {0}, action type = {1}", 0, this._disposed, actionArgs.Action); if (this.Disposed) { if (actionArgs.Action is CimSyncAction) { // unblock the thread waiting for response (actionArgs.Action as CimSyncAction).OnComplete(); } return; } bool isEmpty = this.actionQueue.IsEmpty; this.actionQueue.Enqueue(actionArgs.Action); if (isEmpty) { this.moreActionEvent.Set(); } }
protected override bool PreNewActionEvent(CmdletActionEventArgs args) { WildcardPattern wildcardPattern; DebugHelper.WriteLogEx(); if (args.Action as CimWriteResultObject != null) { CimWriteResultObject action = args.Action as CimWriteResultObject; CimClass result = action.Result as CimClass; if (result != null) { object[] className = new object[1]; className[0] = result.CimSystemProperties.ClassName; DebugHelper.WriteLog("class name = {0}", 1, className); CimGetCimClassContext contextObject = base.ContextObject as CimGetCimClassContext; if (WildcardPattern.ContainsWildcardCharacters(contextObject.ClassName)) { wildcardPattern = new WildcardPattern(contextObject.ClassName, WildcardOptions.IgnoreCase); if (!wildcardPattern.IsMatch(result.CimSystemProperties.ClassName)) { return(false); } } if (contextObject.PropertyName != null) { wildcardPattern = new WildcardPattern(contextObject.PropertyName, WildcardOptions.IgnoreCase); bool flag = false; if (result.CimClassProperties != null) { foreach (CimPropertyDeclaration cimClassProperty in result.CimClassProperties) { object[] name = new object[1]; name[0] = cimClassProperty.Name; DebugHelper.WriteLog("--- property name : {0}", 1, name); if (!wildcardPattern.IsMatch(cimClassProperty.Name)) { continue; } flag = true; break; } } if (!flag) { object[] propertyName = new object[1]; propertyName[0] = contextObject.PropertyName; DebugHelper.WriteLog("Property name does not match: {0}", 1, propertyName); return(flag); } } if (contextObject.MethodName != null) { wildcardPattern = new WildcardPattern(contextObject.MethodName, WildcardOptions.IgnoreCase); bool flag1 = false; if (result.CimClassMethods != null) { foreach (CimMethodDeclaration cimClassMethod in result.CimClassMethods) { object[] objArray = new object[1]; objArray[0] = cimClassMethod.Name; DebugHelper.WriteLog("--- method name : {0}", 1, objArray); if (!wildcardPattern.IsMatch(cimClassMethod.Name)) { continue; } flag1 = true; break; } } if (!flag1) { object[] methodName = new object[1]; methodName[0] = contextObject.MethodName; DebugHelper.WriteLog("Method name does not match: {0}", 1, methodName); return(flag1); } } if (contextObject.QualifierName != null) { wildcardPattern = new WildcardPattern(contextObject.QualifierName, WildcardOptions.IgnoreCase); bool flag2 = false; if (result.CimClassQualifiers != null) { foreach (CimQualifier cimClassQualifier in result.CimClassQualifiers) { object[] name1 = new object[1]; name1[0] = cimClassQualifier.Name; DebugHelper.WriteLog("--- qualifier name : {0}", 1, name1); if (!wildcardPattern.IsMatch(cimClassQualifier.Name)) { continue; } flag2 = true; break; } } if (!flag2) { object[] qualifierName = new object[1]; qualifierName[0] = contextObject.QualifierName; DebugHelper.WriteLog("Qualifer name does not match: {0}", 1, qualifierName); return(flag2); } } object[] className1 = new object[1]; className1[0] = result.CimSystemProperties.ClassName; DebugHelper.WriteLog("CimClass '{0}' is qulified.", 1, className1); return(true); } else { return(true); } } else { return(true); } }
private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actionArgs) { object[] action = new object[2]; action[0] = actionArgs.Action; action[1] = base.Disposed; DebugHelper.WriteLogEx("action is {0}. Disposed {1}", 0, action); if (!base.Disposed) { CimWriteError cimWriteError = actionArgs.Action as CimWriteError; if (cimWriteError != null) { this.exception = cimWriteError.Exception; if (this.ackedEvent.IsSet) { EventHandler<CimSubscriptionEventArgs> eventHandler = this.OnNewSubscriptionResult; if (eventHandler != null) { DebugHelper.WriteLog("Raise an exception event", 2); eventHandler(this, new CimSubscriptionExceptionEventArgs(this.exception)); } object[] objArray = new object[1]; objArray[0] = this.exception; DebugHelper.WriteLog("Got an exception: {0}", 2, objArray); } else { DebugHelper.WriteLogEx("an exception happened", 0); this.ackedEvent.Set(); return; } } CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject; if (cimWriteResultObject != null) { CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult; if (result == null) { if (this.ackedEvent.IsSet) { DebugHelper.WriteLogEx("an ack message should not happen here", 0); } else { DebugHelper.WriteLogEx("an ack message happened", 0); this.ackedEvent.Set(); return; } } else { EventHandler<CimSubscriptionEventArgs> eventHandler1 = this.OnNewSubscriptionResult; if (eventHandler1 != null) { DebugHelper.WriteLog("Raise an result event", 2); eventHandler1(this, new CimSubscriptionResultEventArgs(result)); return; } } } return; } else { return; } }
/// <summary> /// <para> /// Trigger an event that new action available /// </para> /// </summary> /// <param name="action"></param> protected void FireNewActionEvent(CimBaseAction action) { DebugHelper.WriteLogEx(); CmdletActionEventArgs actionArgs = new CmdletActionEventArgs(action); if (!PreNewActionEvent(actionArgs)) { return; } NewCmdletActionHandler temp = this.OnNewCmdletAction; if (temp != null) { temp(this.session, actionArgs); } else { DebugHelper.WriteLog("Ignore action since OnNewCmdletAction is null.", 5); } this.PostNewActionEvent(actionArgs); }
/// <summary> /// Called before new action event /// </summary> /// <param name="args"></param> protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if ((!this.passThru) && (args.Action is CimWriteResultObject)) { // filter out any output object return false; } return true; }
/// <summary> /// Called before new action event /// </summary> /// <param name="args"></param> protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (!(args.Action is CimWriteResultObject)) { // allow all other actions return true; } CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject; CimInstance cimInstance = writeResultObject.Result as CimInstance; if (cimInstance == null) { return true; } DebugHelper.WriteLog("Going to read CimInstance classname = {0}; namespace = {1}", 1, cimInstance.CimSystemProperties.ClassName, cimInstance.CimSystemProperties.Namespace); this.NewCimInstanceOperation.GetCimInstance(cimInstance, this.ContextObject); return false; }
/// <summary> /// Called before new action event /// </summary> /// <param name="args"></param> protected override bool PreNewActionEvent(CmdletActionEventArgs args) { DebugHelper.WriteLogEx(); if (!(args.Action is CimWriteResultObject)) { // allow all other actions return true; } CimWriteResultObject writeResultObject = args.Action as CimWriteResultObject; CimClass cimClass = writeResultObject.Result as CimClass; if (cimClass == null) { return true; } DebugHelper.WriteLog("class name = {0}", 1, cimClass.CimSystemProperties.ClassName); CimGetCimClassContext context = this.ContextObject as CimGetCimClassContext; Debug.Assert(context != null, "Caller should verify that CimGetCimClassContext != NULL."); WildcardPattern pattern; if (WildcardPattern.ContainsWildcardCharacters(context.ClassName)) { pattern = new WildcardPattern(context.ClassName, WildcardOptions.IgnoreCase); if (!pattern.IsMatch(cimClass.CimSystemProperties.ClassName)) { return false; } } if (context.PropertyName != null) { pattern = new WildcardPattern(context.PropertyName, WildcardOptions.IgnoreCase); bool match = false; if (cimClass.CimClassProperties != null) { foreach (CimPropertyDeclaration decl in cimClass.CimClassProperties) { DebugHelper.WriteLog("--- property name : {0}", 1, decl.Name); if (pattern.IsMatch(decl.Name)) { match = true; break; } } } if (!match) { DebugHelper.WriteLog("Property name does not match: {0}", 1, context.PropertyName); return match; } } if (context.MethodName != null) { pattern = new WildcardPattern(context.MethodName, WildcardOptions.IgnoreCase); bool match = false; if (cimClass.CimClassMethods != null) { foreach (CimMethodDeclaration decl in cimClass.CimClassMethods) { DebugHelper.WriteLog("--- method name : {0}", 1, decl.Name); if (pattern.IsMatch(decl.Name)) { match = true; break; } } } if (!match) { DebugHelper.WriteLog("Method name does not match: {0}", 1, context.MethodName); return match; } } if (context.QualifierName != null) { pattern = new WildcardPattern(context.QualifierName, WildcardOptions.IgnoreCase); bool match = false; if (cimClass.CimClassQualifiers != null) { foreach (CimQualifier qualifier in cimClass.CimClassQualifiers) { DebugHelper.WriteLog("--- qualifier name : {0}", 1, qualifier.Name); if (pattern.IsMatch(qualifier.Name)) { match = true; break; } } } if (!match) { DebugHelper.WriteLog("Qualifier name does not match: {0}", 1, context.QualifierName); return match; } } DebugHelper.WriteLog("CimClass '{0}' is qualified.", 1, cimClass.CimSystemProperties.ClassName); return true; }
protected void FireNewActionEvent(CimBaseAction action) { DebugHelper.WriteLogEx(); CmdletActionEventArgs cmdletActionEventArg = new CmdletActionEventArgs(action); if (this.PreNewActionEvent(cmdletActionEventArg)) { CimSessionProxy.NewCmdletActionHandler newCmdletActionHandler = this.OnNewCmdletAction; if (newCmdletActionHandler == null) { DebugHelper.WriteLog("Ignore action since OnNewCmdletAction is null.", 5); } else { newCmdletActionHandler(this.session, cmdletActionEventArg); } this.PostNewActionEvent(cmdletActionEventArg); return; } else { return; } }
private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actionArgs) { object[] action = new object[2]; action[0] = actionArgs.Action; action[1] = base.Disposed; DebugHelper.WriteLogEx("action is {0}. Disposed {1}", 0, action); if (!base.Disposed) { CimWriteError cimWriteError = actionArgs.Action as CimWriteError; if (cimWriteError != null) { this.exception = cimWriteError.Exception; if (this.ackedEvent.IsSet) { EventHandler <CimSubscriptionEventArgs> eventHandler = this.OnNewSubscriptionResult; if (eventHandler != null) { DebugHelper.WriteLog("Raise an exception event", 2); eventHandler(this, new CimSubscriptionExceptionEventArgs(this.exception)); } object[] objArray = new object[1]; objArray[0] = this.exception; DebugHelper.WriteLog("Got an exception: {0}", 2, objArray); } else { DebugHelper.WriteLogEx("an exception happened", 0); this.ackedEvent.Set(); return; } } CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject; if (cimWriteResultObject != null) { CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult; if (result == null) { if (this.ackedEvent.IsSet) { DebugHelper.WriteLogEx("an ack message should not happen here", 0); } else { DebugHelper.WriteLogEx("an ack message happened", 0); this.ackedEvent.Set(); return; } } else { EventHandler <CimSubscriptionEventArgs> eventHandler1 = this.OnNewSubscriptionResult; if (eventHandler1 != null) { DebugHelper.WriteLog("Raise an result event", 2); eventHandler1(this, new CimSubscriptionResultEventArgs(result)); return; } } } return; } else { return; } }
/// <summary> /// <para> /// Handler used to handle new action event from /// <seealso cref="CimSessionProxy"/> object. /// </para> /// </summary> /// <param name="cimSession"> /// <seealso cref="CimSession"/> object raised the event /// </param> /// <param name="actionArgs">event argument</param> private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actionArgs) { DebugHelper.WriteLogEx("action is {0}. Disposed {1}", 0, actionArgs.Action, this.Disposed); if (this.Disposed) { return; } // NOTES: should move after this.Disposed, but need to log the exception CimWriteError cimWriteError = actionArgs.Action as CimWriteError; if (cimWriteError != null) { this.exception = cimWriteError.Exception; if (!this.ackedEvent.IsSet) { // an exception happened DebugHelper.WriteLogEx("an exception happened", 0); this.ackedEvent.Set(); return; } EventHandler<CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an exception event", 2); temp(this, new CimSubscriptionExceptionEventArgs(this.exception)); } DebugHelper.WriteLog("Got an exception: {0}", 2, exception); } CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject; if (cimWriteResultObject != null) { CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult; if (result != null) { EventHandler<CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an result event", 2); temp(this, new CimSubscriptionResultEventArgs(result)); } } else { if (!this.ackedEvent.IsSet) { // an ACK message returned DebugHelper.WriteLogEx("an ack message happened", 0); this.ackedEvent.Set(); return; } else { DebugHelper.WriteLogEx("an ack message should not happen here", 0); } } } }
/// <summary> /// Called before new action event /// </summary> /// <param name="args"></param> protected virtual bool PreNewActionEvent(CmdletActionEventArgs args) { return true; }
/// <summary> /// Called after new action event /// </summary> /// <param name="args"></param> protected virtual void PostNewActionEvent(CmdletActionEventArgs args) { }
/// <summary> /// <para> /// Handler used to handle new action event from /// <seealso cref="CimSessionProxy"/> object. /// </para> /// </summary> /// <param name="cimSession"> /// <seealso cref="CimSession"/> object raised the event /// </param> /// <param name="actionArgs">event argument</param> private void CimIndicationHandler(object cimSession, CmdletActionEventArgs actionArgs) { DebugHelper.WriteLogEx("action is {0}. Disposed {1}", 0, actionArgs.Action, this.Disposed); if (this.Disposed) { return; } // NOTES: should move after this.Disposed, but need to log the exception CimWriteError cimWriteError = actionArgs.Action as CimWriteError; if (cimWriteError != null) { this.exception = cimWriteError.Exception; if (!this.ackedEvent.IsSet) { // an exception happened DebugHelper.WriteLogEx("an exception happened", 0); this.ackedEvent.Set(); return; } EventHandler <CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an exception event", 2); temp(this, new CimSubscriptionExceptionEventArgs(this.exception)); } DebugHelper.WriteLog("Got an exception: {0}", 2, exception); } CimWriteResultObject cimWriteResultObject = actionArgs.Action as CimWriteResultObject; if (cimWriteResultObject != null) { CimSubscriptionResult result = cimWriteResultObject.Result as CimSubscriptionResult; if (result != null) { EventHandler <CimSubscriptionEventArgs> temp = this.OnNewSubscriptionResult; if (temp != null) { DebugHelper.WriteLog("Raise an result event", 2); temp(this, new CimSubscriptionResultEventArgs(result)); } } else { if (!this.ackedEvent.IsSet) { // an ACK message returned DebugHelper.WriteLogEx("an ack message happened", 0); this.ackedEvent.Set(); return; } else { DebugHelper.WriteLogEx("an ack message should not happen here", 0); } } } }
protected override bool PreNewActionEvent(CmdletActionEventArgs args) { WildcardPattern wildcardPattern; DebugHelper.WriteLogEx(); if (args.Action as CimWriteResultObject != null) { CimWriteResultObject action = args.Action as CimWriteResultObject; CimClass result = action.Result as CimClass; if (result != null) { object[] className = new object[1]; className[0] = result.CimSystemProperties.ClassName; DebugHelper.WriteLog("class name = {0}", 1, className); CimGetCimClassContext contextObject = base.ContextObject as CimGetCimClassContext; if (WildcardPattern.ContainsWildcardCharacters(contextObject.ClassName)) { wildcardPattern = new WildcardPattern(contextObject.ClassName, WildcardOptions.IgnoreCase); if (!wildcardPattern.IsMatch(result.CimSystemProperties.ClassName)) { return false; } } if (contextObject.PropertyName != null) { wildcardPattern = new WildcardPattern(contextObject.PropertyName, WildcardOptions.IgnoreCase); bool flag = false; if (result.CimClassProperties != null) { foreach (CimPropertyDeclaration cimClassProperty in result.CimClassProperties) { object[] name = new object[1]; name[0] = cimClassProperty.Name; DebugHelper.WriteLog("--- property name : {0}", 1, name); if (!wildcardPattern.IsMatch(cimClassProperty.Name)) { continue; } flag = true; break; } } if (!flag) { object[] propertyName = new object[1]; propertyName[0] = contextObject.PropertyName; DebugHelper.WriteLog("Property name does not match: {0}", 1, propertyName); return flag; } } if (contextObject.MethodName != null) { wildcardPattern = new WildcardPattern(contextObject.MethodName, WildcardOptions.IgnoreCase); bool flag1 = false; if (result.CimClassMethods != null) { foreach (CimMethodDeclaration cimClassMethod in result.CimClassMethods) { object[] objArray = new object[1]; objArray[0] = cimClassMethod.Name; DebugHelper.WriteLog("--- method name : {0}", 1, objArray); if (!wildcardPattern.IsMatch(cimClassMethod.Name)) { continue; } flag1 = true; break; } } if (!flag1) { object[] methodName = new object[1]; methodName[0] = contextObject.MethodName; DebugHelper.WriteLog("Method name does not match: {0}", 1, methodName); return flag1; } } if (contextObject.QualifierName != null) { wildcardPattern = new WildcardPattern(contextObject.QualifierName, WildcardOptions.IgnoreCase); bool flag2 = false; if (result.CimClassQualifiers != null) { foreach (CimQualifier cimClassQualifier in result.CimClassQualifiers) { object[] name1 = new object[1]; name1[0] = cimClassQualifier.Name; DebugHelper.WriteLog("--- qualifier name : {0}", 1, name1); if (!wildcardPattern.IsMatch(cimClassQualifier.Name)) { continue; } flag2 = true; break; } } if (!flag2) { object[] qualifierName = new object[1]; qualifierName[0] = contextObject.QualifierName; DebugHelper.WriteLog("Qualifer name does not match: {0}", 1, qualifierName); return flag2; } } object[] className1 = new object[1]; className1[0] = result.CimSystemProperties.ClassName; DebugHelper.WriteLog("CimClass '{0}' is qulified.", 1, className1); return true; } else { return true; } } else { return true; } }