/// <summary> /// Execute void method. /// </summary> internal void ExecuteVoidMethod(PSHost clientHost) { // The clientHost can be null if the user creates a runspace object without providing // a host parameter. if (clientHost == null) { return; } RemoteRunspace remoteRunspaceToClose = null; if (this.IsSetShouldExitOrPopRunspace) { remoteRunspaceToClose = GetRemoteRunspaceToClose(clientHost); } try { object targetObject = this.SelectTargetObject(clientHost); MyMethodBase.Invoke(targetObject, Parameters); } finally { if (remoteRunspaceToClose != null) { remoteRunspaceToClose.Close(); } } }
public static void LogsFailAndThrow(MyMethodBase method, string note) { Logs(Log.StatusX.Fail, method.Name, note); throw new Exception(note); }