internal void RemoveCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase cmdlet) { DebugHelper.WriteLogEx(); string str = cimInstance.ToString(); if (cmdlet.ShouldProcess(str, "Remove-CimInstance")) { CimRemoveCimInstanceContext cimRemoveCimInstanceContext = context as CimRemoveCimInstanceContext; CimSessionProxy cimSessionProxy = base.CreateCimSessionProxy(cimRemoveCimInstanceContext.Proxy); cimSessionProxy.DeleteInstanceAsync(cimRemoveCimInstanceContext.Namespace, cimInstance); return; } else { return; } }
/// <summary> /// <para> /// Remove <see cref="CimInstance"/> from namespace specified in cmdlet /// </para> /// </summary> /// <param name="cimInstance"></param> internal void RemoveCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase cmdlet) { DebugHelper.WriteLogEx(); string target = cimInstance.ToString(); if (!cmdlet.ShouldProcess(target, action)) { return; } CimRemoveCimInstanceContext removeContext = context as CimRemoveCimInstanceContext; Debug.Assert(removeContext != null, "CimRemoveCimInstance::RemoveCimInstance should has CimRemoveCimInstanceContext != NULL."); CimSessionProxy proxy = CreateCimSessionProxy(removeContext.Proxy); proxy.DeleteInstanceAsync(removeContext.Namespace, cimInstance); }
public void InvokeCimMethodOnCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase operation) { DebugHelper.WriteLogEx(); CimInvokeCimMethod.CimInvokeCimMethodContext cimInvokeCimMethodContext = context as CimInvokeCimMethod.CimInvokeCimMethodContext; object[] methodName = new object[1]; methodName[0] = cimInvokeCimMethodContext.MethodName; string str = string.Format(CultureInfo.CurrentUICulture, "Invoke-CimMethod: {0}", methodName); if (operation.ShouldProcess(cimInstance.ToString(), str)) { CimSessionProxy cimSessionProxy = base.CreateCimSessionProxy(cimInvokeCimMethodContext.Proxy); cimSessionProxy.InvokeMethodAsync(cimInvokeCimMethodContext.Namespace, cimInstance, cimInvokeCimMethodContext.MethodName, cimInvokeCimMethodContext.ParametersCollection); return; } else { return; } }
/// <summary> /// <para> /// Set <see cref="CimInstance"/> with properties specified in cmdlet /// </para> /// </summary> /// <param name="cimInstance"></param> public void SetCimInstance(CimInstance cimInstance, CimSetCimInstanceContext context, CmdletOperationBase cmdlet) { DebugHelper.WriteLog("CimSetCimInstance::SetCimInstance", 4); if (!cmdlet.ShouldProcess(cimInstance.ToString(), action)) { return; } Exception exception = null; if (!SetProperty(context.Property, ref cimInstance, ref exception)) { cmdlet.ThrowTerminatingError(exception, action); return; } CimSessionProxy proxy = CreateCimSessionProxy(context.Proxy, context.PassThru); proxy.ModifyInstanceAsync(cimInstance.CimSystemProperties.Namespace, cimInstance); }
/// <summary> /// <para> /// Invoke cimmethod on given <see cref="CimInstance"/> /// </para> /// </summary> /// <param name="cimInstance"></param> public void InvokeCimMethodOnCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase operation) { DebugHelper.WriteLogEx(); CimInvokeCimMethodContext cimInvokeCimMethodContext = context as CimInvokeCimMethodContext; Debug.Assert(cimInvokeCimMethodContext != null, "CimInvokeCimMethod::InvokeCimMethodOnCimInstance should has CimInvokeCimMethodContext != NULL."); string action = string.Format(CultureInfo.CurrentUICulture, actionTemplate, cimInvokeCimMethodContext.MethodName); if (!operation.ShouldProcess(cimInstance.ToString(), action)) { return; } CimSessionProxy proxy = CreateCimSessionProxy(cimInvokeCimMethodContext.Proxy); proxy.InvokeMethodAsync( cimInvokeCimMethodContext.Namespace, cimInstance, cimInvokeCimMethodContext.MethodName, cimInvokeCimMethodContext.ParametersCollection); }
public override void Execute(CmdletOperationBase cmdlet) { bool flag; ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet"); bool flag1 = false; bool flag2 = false; CimPromptType cimPromptType = this.prompt; switch (cimPromptType) { case CimPromptType.None: { flag = cmdlet.ShouldProcess(this.message); if (!flag) { if (flag) { break; } this.responseType = CimResponseType.None; break; } else { this.responseType = CimResponseType.Yes; break; } } case CimPromptType.Critical: { flag = cmdlet.ShouldContinue(this.message, "caption", ref flag1, ref flag2); if (!flag1) { if (!flag2) { if (!flag) { if (flag) { break; } this.responseType = CimResponseType.None; break; } else { this.responseType = CimResponseType.Yes; break; } } else { this.responseType = CimResponseType.NoToAll; break; } } else { this.responseType = CimResponseType.YesToAll; break; } } } this.OnComplete(); }
/// <summary> /// <para> /// Prompt user with the given message and prepared whatif message. /// </para> /// </summary> /// <param name="cmdlet"> /// cmdlet wrapper object, to which write result. /// <see cref="CmdletOperationBase"/> for details. /// </param> public override void Execute(CmdletOperationBase cmdlet) { ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet"); bool yestoall = false; bool notoall = false; bool result = false; switch (this.prompt) { case CimPromptType.Critical: // NOTES: prepare the whatif message and caption try { result = cmdlet.ShouldContinue(Message, "caption", ref yestoall, ref notoall); if (yestoall) { this.responseType = CimResponseType.YesToAll; } else if (notoall) { this.responseType = CimResponseType.NoToAll; } else if (result) { this.responseType = CimResponseType.Yes; } else if (!result) { this.responseType = CimResponseType.No; } } catch { this.responseType = CimResponseType.NoToAll; throw; } finally { // unblocking the waiting thread this.OnComplete(); } break; case CimPromptType.Normal: try { result = cmdlet.ShouldProcess(Message); if (result) { this.responseType = CimResponseType.Yes; } else if (!result) { this.responseType = CimResponseType.No; } } catch { this.responseType = CimResponseType.NoToAll; throw; } finally { // unblocking the waiting thread this.OnComplete(); } break; default: break; } this.OnComplete(); }
/// <summary> /// <para> /// Set <see cref="CimInstance"/> with properties specified in cmdlet /// </para> /// </summary> /// <param name="cimInstance"></param> public void SetCimInstance(CimInstance cimInstance, CimSetCimInstanceContext context, CmdletOperationBase cmdlet) { DebugHelper.WriteLog("CimSetCimInstance::SetCimInstance", 4); if (!cmdlet.ShouldProcess(cimInstance.ToString(), action)) { return; } Exception exception = null; if (!SetProperty(context.Property, ref cimInstance, ref exception)) { cmdlet.ThrowTerminatingError(exception, action); return; } CimSessionProxy proxy = CreateCimSessionProxy(context.Proxy, context.PassThru); proxy.ModifyInstanceAsync(cimInstance.CimSystemProperties.Namespace, cimInstance); }
/// <summary> /// <para> /// Remove <see cref="CimInstance"/> from namespace specified in cmdlet /// </para> /// </summary> /// <param name="cimInstance"></param> internal void RemoveCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase cmdlet) { DebugHelper.WriteLogEx(); string target = cimInstance.ToString(); if (!cmdlet.ShouldProcess(target, action)) { return; } CimRemoveCimInstanceContext removeContext = context as CimRemoveCimInstanceContext; Debug.Assert(removeContext != null, "CimRemoveCimInstance::RemoveCimInstance should has CimRemoveCimInstanceContext != NULL."); CimSessionProxy proxy = CreateCimSessionProxy(removeContext.Proxy); proxy.DeleteInstanceAsync(removeContext.Namespace, cimInstance); }
/// <summary> /// <para> /// Prompt user with the given message and prepared whatif message. /// </para> /// </summary> /// <param name="cmdlet"> /// cmdlet wrapper object, to which write result. /// <see cref="CmdletOperationBase"/> for details. /// </param> public override void Execute(CmdletOperationBase cmdlet) { ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet"); bool yestoall = false; bool notoall = false; bool result = false; switch (this.prompt) { case CimPromptType.Critical: // NOTES: prepare the whatif message and caption try { result = cmdlet.ShouldContinue(message, "caption", ref yestoall, ref notoall); if (yestoall) { this.responseType = CimResponseType.YesToAll; } else if (notoall) { this.responseType = CimResponseType.NoToAll; } else if (result) { this.responseType = CimResponseType.Yes; } else if (!result) { this.responseType = CimResponseType.No; } } catch { this.responseType = CimResponseType.NoToAll; throw; } finally { // unblocking the waiting thread this.OnComplete(); } break; case CimPromptType.Normal: try { result = cmdlet.ShouldProcess(message); if (result) { this.responseType = CimResponseType.Yes; } else if (!result) { this.responseType = CimResponseType.No; } } catch { this.responseType = CimResponseType.NoToAll; throw; } finally { // unblocking the waiting thread this.OnComplete(); } break; default: break; } this.OnComplete(); }
public void InvokeCimMethodOnCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase operation) { DebugHelper.WriteLogEx(); CimInvokeCimMethod.CimInvokeCimMethodContext cimInvokeCimMethodContext = context as CimInvokeCimMethod.CimInvokeCimMethodContext; object[] methodName = new object[1]; methodName[0] = cimInvokeCimMethodContext.MethodName; string str = string.Format(CultureInfo.CurrentUICulture, "Invoke-CimMethod: {0}", methodName); if (operation.ShouldProcess(cimInstance.ToString(), str)) { CimSessionProxy cimSessionProxy = base.CreateCimSessionProxy(cimInvokeCimMethodContext.Proxy); cimSessionProxy.InvokeMethodAsync(cimInvokeCimMethodContext.Namespace, cimInstance, cimInvokeCimMethodContext.MethodName, cimInvokeCimMethodContext.ParametersCollection); return; } else { return; } }
public override void Execute(CmdletOperationBase cmdlet) { bool flag; ValidationHelper.ValidateNoNullArgument(cmdlet, "cmdlet"); bool flag1 = false; bool flag2 = false; CimPromptType cimPromptType = this.prompt; switch (cimPromptType) { case CimPromptType.None: { flag = cmdlet.ShouldProcess(this.message); if (!flag) { if (flag) { break; } this.responseType = CimResponseType.None; break; } else { this.responseType = CimResponseType.Yes; break; } } case CimPromptType.Critical: { flag = cmdlet.ShouldContinue(this.message, "caption", ref flag1, ref flag2); if (!flag1) { if (!flag2) { if (!flag) { if (flag) { break; } this.responseType = CimResponseType.None; break; } else { this.responseType = CimResponseType.Yes; break; } } else { this.responseType = CimResponseType.NoToAll; break; } } else { this.responseType = CimResponseType.YesToAll; break; } } } this.OnComplete(); }
internal void RemoveCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase cmdlet) { DebugHelper.WriteLogEx(); string str = cimInstance.ToString(); if (cmdlet.ShouldProcess(str, "Remove-CimInstance")) { CimRemoveCimInstanceContext cimRemoveCimInstanceContext = context as CimRemoveCimInstanceContext; CimSessionProxy cimSessionProxy = base.CreateCimSessionProxy(cimRemoveCimInstanceContext.Proxy); cimSessionProxy.DeleteInstanceAsync(cimRemoveCimInstanceContext.Namespace, cimInstance); return; } else { return; } }
/// <summary> /// <para> /// Invoke cimmethod on given <see cref="CimInstance"/> /// </para> /// </summary> /// <param name="cimInstance"></param> public void InvokeCimMethodOnCimInstance(CimInstance cimInstance, XOperationContextBase context, CmdletOperationBase operation) { DebugHelper.WriteLogEx(); CimInvokeCimMethodContext cimInvokeCimMethodContext = context as CimInvokeCimMethodContext; Debug.Assert(cimInvokeCimMethodContext != null, "CimInvokeCimMethod::InvokeCimMethodOnCimInstance should has CimInvokeCimMethodContext != NULL."); string action = string.Format(CultureInfo.CurrentUICulture, actionTemplate, cimInvokeCimMethodContext.MethodName); if (!operation.ShouldProcess(cimInstance.ToString(), action)) { return; } CimSessionProxy proxy = CreateCimSessionProxy(cimInvokeCimMethodContext.Proxy); proxy.InvokeMethodAsync( cimInvokeCimMethodContext.Namespace, cimInstance, cimInvokeCimMethodContext.MethodName, cimInvokeCimMethodContext.ParametersCollection); }