public AutoMigrationStateSaver(
     IStateSaver stateSaver,
     IStateSaverMigration stateSaverMigration)
 {
     _stateSaver = stateSaver;
     _migrated   = new Lazy <Task>(stateSaverMigration.MigrateAsync);
 }
Пример #2
0
 public MetricsStateSaver(
     IStateSaver stateSaver,
     IClaptrapDesign claptrapDesign)
 {
     _stateSaver     = stateSaver;
     _claptrapDesign = claptrapDesign;
 }
Пример #3
0
 public Game(IMediator mediator, IStateSaver stateSaver)
 {
     this._mediator   = mediator;
     this._stateSaver = stateSaver;
     this._items      = new List <IItem>();
     this._characters = new List <Character>();
     this._gameEvents = new List <StoredGameEvent>();
 }
Пример #4
0
        public UserMemoryRepository(IGenerator <int> idGenerator, IStateSaver <UserRepositorySnapshot> stateSaver)
        {
            if (idGenerator == null)
            {
                throw new ArgumentNullException($"{nameof(idGenerator)} argument is null");
            }

            this.idGenerator = idGenerator;
            this.stateSaver  = stateSaver;
        }
Пример #5
0
 public StateSavingFlow(
     StateSavingOptions stateSavingOptions,
     IStateSaver stateSaver,
     ILogger <StateSavingFlow> logger)
 {
     _stateSavingOptions = stateSavingOptions;
     _stateSaver         = stateSaver;
     _logger             = logger;
     _nextStateSeq       = new Subject <IState>();
 }
Пример #6
0
 public void Load(Dictionary <string, object> data)
 {
     foreach (string componentName in rememberComponents)
     {
         Component component = GetComponent(componentName);
         if (component != null)
         {
             IStateSaver saver = component as IStateSaver;
             if (saver != null)
             {
                 saver.OnLoad(data[componentName]);
             }
             else
             {
                 AutoLoad(component, data[componentName]);
             }
         }
     }
 }
Пример #7
0
        public Dictionary <string, object> Save()
        {
            var test = new Dictionary <string, object>();

            foreach (string componentName in rememberComponents)
            {
                Component component = GetComponent(componentName);
                if (component != null)
                {
                    IStateSaver saver = component as IStateSaver;
                    if (saver != null)
                    {
                        test[componentName] = saver.OnSave();
                    }
                    else
                    {
                        test[componentName] = AutoData(component);
                    }
                }
            }
            return(test);
        }
 public MyStateSaver(IStateSaver stateSaver) : base(stateSaver)
 {
 }
Пример #9
0
 public WorldSimulator(IStateSaver stateSaver)
 {
     _stateSaver = stateSaver;
 }
Пример #10
0
 public MetricsStateSaver(
     IStateSaver stateSaver)
 {
     _stateSaver = stateSaver;
 }
        public MachineControlsViewModel(SimpleSimulator simulator, IUserInputService userInputService, IDialogServiceAdapter dialogServiceAdapter, IStateSaver stateSaver)
        {
            _simulator = simulator;

            NewCommand = new DelegateCommand(() => dialogServiceAdapter.ShowAssemblyEditorDialog(), () => simulator.Machine.State != Machine.MachineState.Running);

            OpenCommand = new DelegateCommand(async() =>
            {
                FileInfo file = userInputService.GetOpenFileName();

                if (file != null)
                {
                    if (file.Extension.Equals(".prg", StringComparison.OrdinalIgnoreCase))
                    {
                        Memory memory = await stateSaver.LoadMemoryAsync(file);
                        simulator.Memory.LoadByteArray(memory.ToByteArray());
                    }
                    else if (file.Extension.Equals(".asm", StringComparison.OrdinalIgnoreCase))
                    {
                        dialogServiceAdapter.ShowAssemblyEditorDialog(File.ReadAllText(file.FullName));
                    }
                }
            }, () => simulator.Machine.State != Machine.MachineState.Running);

            SaveCommand = new DelegateCommand(async() =>
            {
                FileInfo file = userInputService.GetSaveFileName();

                if (file != null)
                {
                    await stateSaver.SaveMemoryAsync(simulator.Memory, file);
                }
            }, () => simulator.Machine.State != Machine.MachineState.Running);

            RunCommand = new DelegateCommand(async() => await simulator.Machine.RunAsync(), () => simulator.Machine.State != Machine.MachineState.Running);

            StepCommand = new DelegateCommand(() => simulator.Machine.Step(), () => simulator.Machine.State != Machine.MachineState.Running);

            BreakCommand = new DelegateCommand(() => simulator.Machine.Break(), () => simulator.Machine.State == Machine.MachineState.Running);

            ClearMemoryCommand = new DelegateCommand(() => simulator.Memory.Clear());

            ClearRegistersCommand = new DelegateCommand(() => simulator.Registers.Clear());

            simulator.Machine.StateChanged += () =>
            {
                NewCommand.RaiseCanExecuteChanged();
                OpenCommand.RaiseCanExecuteChanged();
                SaveCommand.RaiseCanExecuteChanged();
                RunCommand.RaiseCanExecuteChanged();
                StepCommand.RaiseCanExecuteChanged();
                BreakCommand.RaiseCanExecuteChanged();
            };
        }
Пример #12
0
 public void TestInit()
 {
     this.memento = new Saver<IGameModel>();
     this.logic  = new LogicProvider(new MatrixValidator(), new RandomNumberGenerator());
 }
 protected DecoratedStateSaver(
     IStateSaver stateSaver)
 {
     StateSaver = stateSaver;
 }
Пример #14
0
 public XmlSerializer(IStateSaver stateSaver)
     : base(stateSaver)
 {
     _saver = stateSaver;
 }