Dev2.DynamicServices.FileSystemInstanceStore.BeginTryCommand C# (CSharp) Method

BeginTryCommand() protected method

protected BeginTryCommand ( System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, System.TimeSpan timeout, AsyncCallback callback, object state ) : IAsyncResult
context System.Runtime.DurableInstancing.InstancePersistenceContext
command System.Runtime.DurableInstancing.InstancePersistenceCommand
timeout System.TimeSpan
callback AsyncCallback
state object
return IAsyncResult
        protected override IAsyncResult BeginTryCommand(
            InstancePersistenceContext context,
            InstancePersistenceCommand command,
            TimeSpan timeout, AsyncCallback callback, object state)
        {

            switch(command.GetType().Name)
            {
                case "CreateWorkflowOwnerCommand":

                    Func<Exception> createFunc = () => ProcessCreateWorkflowOwner(context,
                                                                                  command as CreateWorkflowOwnerCommand);

                    return createFunc.BeginInvoke(ar =>
                        {
                            Exception ex = createFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "LoadWorkflowCommand":
                    Func<Exception> loadFunc = () => ProcessLoadWorkflow(context,
                                                                         command as LoadWorkflowCommand);

                    return loadFunc.BeginInvoke(ar =>
                        {
                            Exception ex = loadFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "LoadWorkflowByInstanceKeyCommand":
                    Func<Exception> loadByKeyFunc = () => ProcessLoadWorkflowByInstanceKey(context,
                                                                                           command as LoadWorkflowByInstanceKeyCommand);

                    return loadByKeyFunc.BeginInvoke(ar =>
                        {
                            Exception ex = loadByKeyFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                case "SaveWorkflowCommand":
                    Func<Exception> saveFunc = () => ProcessSaveWorkflow(context,
                                                                         command as SaveWorkflowCommand);

                    return saveFunc.BeginInvoke(ar =>
                        {
                            Exception ex = saveFunc.EndInvoke(ar);
                            callback(new InstanceStoreAsyncResult(ar, ex));
                        }, state);

                default:
                    return base.BeginTryCommand(
                        context, command, timeout, callback, state);
            }


        }