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);
}
}