public CommandExecutedEventArgs(ulong entryId, Command command, DateTime executed, TimeSpan executionTime)
 {
     JournalEntryId = entryId;
     Command = command;
     StartTime = executed;
     Duration = executionTime;
 }
Beispiel #2
0
 public override object ExecuteCommand(Command command)
 {
     object result = null;
     try
     {
         Model modelOut = null;
         if (command is IImmutabilityCommand)
         {
             var typedCommand = command as IImmutabilityCommand;
             modelOut = typedCommand.Execute(_model);
         }
         else if (command is IImmutabilityCommandWithResult)
         {
             var typedCommand = command as IImmutabilityCommandWithResult;
             var tuple = typedCommand.Execute(_model);
             UnpackTuple(tuple, out modelOut, out result);
         }
         else throw new InvalidOperationException("Command type not supported by this kernel");
         if (modelOut == null) throw new InvalidOperationException("Command returned null model");
         _model = modelOut;
         return result;
     }
     catch (Exception ex)
     {
         throw new CommandAbortedException("Command failed, see inner exception for details", ex);
     }
 }
Beispiel #3
0
 public CommandExecutedEventArgs(ulong entryId, Command command, DateTime executed, TimeSpan executionTime, IEnumerable<IEvent> events)
 {
     JournalEntryId = entryId;
     Command = command;
     StartTime = executed;
     Duration = executionTime;
     Events = events.ToArray();
 }
Beispiel #4
0
        public override object ExecuteCommand(Command command)
        {
            try
            {
                _synchronizer.EnterUpgrade();
                command.PrepareStub(_model);
                _synchronizer.EnterWrite();
                return command.ExecuteStub(_model);

            }
            finally
            {
                _synchronizer.Exit();
            }
        }
Beispiel #5
0
 public override object ExecuteCommand(Command command)
 {
     try
     {
         _synchronizer.EnterUpgrade();
         command.PrepareStub(_model);
         _synchronizer.EnterWrite();
         var result = command.ExecuteStub(_model);
         _model.Revision++;
         return result;
     }
     finally
     {
         _synchronizer.Exit();
     }
 }
Beispiel #6
0
        /// <summary>
        /// Apply the command to the food taster. If it succeeds, apply to the real model.
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        public override object ExecuteCommand(Command command)
        {
            try
            {
                command.PrepareStub(_foodTaster);
                command.ExecuteStub(_foodTaster); //outofmemory,commandaborted, unhandled user
            }
            catch (CommandAbortedException)
            {
                throw;
            }
            catch (OutOfMemoryException)
            {
                throw;
            }
            catch (Exception ex)
            {
                _foodTaster = _formatter.Clone(Model); //reset
                throw new CommandAbortedException("Royal taster died of food poisoning, see inner exception for details", ex);
            }

            return base.ExecuteCommand(command);
        }
Beispiel #7
0
 internal override void Apply(ref Command command)
 {
     if (!HasIsolationAttribute(command, IsolationLevel.Input) && ! command.GetType().HasImmutableAttribute())
         command = Formatter.Clone(command);
 }
Beispiel #8
0
 public CommandExecutingEventArgs(Command command)
 {
     Command = command;
 }
Beispiel #9
0
 public TResult Execute <TResult>(Command <TModel, TResult> command)
 {
     return((TResult)base.Execute(command));
 }
Beispiel #10
0
 public void Execute(Command <TModel> command)
 {
     base.Execute(command);
 }
Beispiel #11
0
 internal abstract void Apply(ref Command command);