public string FireBeforePerforming(object caller, string operationName, Dictionary <string, object> parameters) { IsInitiated(); INotificationManager icaller = caller as INotificationManager; if (icaller == null) { throw new InvalidOperationException("Caller is not INotificationManager type. Implement INotificationManager to use methods."); } if (!(icaller.GetPoissibleOperationNames().Contains(operationName))) { throw new InvalidOperationException(string.Format("Caller does not support '{0}' operation.", operationName)); } //add operation information OperationInformation opInfo = new OperationInformation(caller, operationName, parameters); this._CurrentOperationsInformation.Add(opInfo.OperationId, opInfo); //fire event if (this.BeforePerforming != null) { this.BeforePerforming(opInfo); } return(opInfo.OperationId); }
public void FireAfterPerforming(object caller, string operationId, Dictionary <string, object> parameters) { IsInitiated(); INotificationManager icaller = caller as INotificationManager; if (icaller == null) { throw new InvalidOperationException("Caller is not INotificationManager type. Implement INotificationManager to use methods."); } if (this._CurrentOperationsInformation.ContainsKey(operationId)) { OperationInformation opInfo = (OperationInformation)this._CurrentOperationsInformation[operationId]; if (opInfo.Parameters != null) { //Lets have all the available parameters Dictionary <string, object> modifiedParam = new Dictionary <string, object>(); foreach (KeyValuePair <string, object> param in opInfo.Parameters) { if (!opInfo.Parameters.ContainsKey(param.Key)) { opInfo.Parameters.Add(param.Key, param.Value); } else { modifiedParam.Add(param.Key, param.Value); } } foreach (KeyValuePair <string, object> param in modifiedParam) { opInfo.Parameters[param.Key] = param.Value; } } else { opInfo.Parameters = parameters; } if (this.AfterPerforming != null) { this.AfterPerforming(opInfo); } this._CurrentOperationsInformation.Remove(operationId); } else { throw new ArgumentException(string.Format("There is no operation initiated with id {0}. Or the operation has been expired", operationId)); } }