public void PerformOperation(Type operationType, Parameters parameters, Action <Parameters> completeHandler = null, Action <Exception> errorHandler = null)
        {
            var group = new OperationGroup();

            group.AddOperation(operationType, parameters);
            PerformGroup(group, null, completeHandler, errorHandler);
        }
        private void AddGroupToQueue(OperationGroup group, Parameters parameters)
        {
            if (group.Credentials != null && group.Credentials.Count > 0)
            {
                var credentials = new Parameters();
                credentials.Add("Credentials", group.Credentials);
                group.AddOperationToStart(typeof(SecurityOperation), credentials);
            }

            var groupContainer = new GroupContainer();

            groupContainer.Group      = group;
            groupContainer.Parameters = parameters;
            lock (SetLock) {
                MainQueue.Enqueue(groupContainer);
                LockEvent.Set();
            }
        }
        private void ExecuteGroup(OperationGroup group, Parameters parameters)
        {
            Parameters groupResults = new Parameters();

            foreach (var operationContainer in group.Operations)
            {
                Operation operation = (Operation)Activator.CreateInstance(operationContainer.OperationType);
                try {
                    groupResults.AddParameters(operationContainer.Parameters);
                    DepedencyContainer.ResolveDependencies(operation, groupResults);

                    operation.Execute();

                    Parameters results = operation.Result;
                    groupResults.AddParameters(results);
                    if (operationContainer.CompleteHandler != null)
                    {
                        operationContainer.CompleteHandler(results);
                    }
                } catch (Exception e) {
                    if (operationContainer.ErrorHandler != null)
                    {
                        operationContainer.ErrorHandler(e);
                    }
                    if (group.ErrorHandler != null)
                    {
                        group.ErrorHandler(e);
                    }
                    return;
                }
            }

            if (group.CompleteHandler != null)
            {
                group.CompleteHandler(groupResults);
            }
        }
 public void PerformGroup(OperationGroup group, Parameters parameters, Action <Parameters> completeHandler = null, Action <Exception> errorHandler = null)
 {
     group.CompleteHandler = completeHandler;
     group.ErrorHandler    = errorHandler;
     AddGroupToQueue(group, parameters);
 }