Exemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionObserver"/> class.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
        public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("collection", collection);

            _weakEventListener = this.SubscribeToWeakCollectionChangedEvent(collection, OnCollectionChanged);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionObserver"/> class.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
        public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("collection", collection);

            _collection = collection;
            _collection.CollectionChanged += OnCollectionChanged;
        }
Exemplo n.º 3
0
 public TicketsController(IValidationService validationService,
                          IMementoService mementoService,
                          ITicketService ticketService)
 {
     this.validationService = validationService;
     this.mementoService    = mementoService;
     this.ticketService     = ticketService;
 }
Exemplo n.º 4
0
        public EditorViewModel(StudioStateModel studioState,
            IMementoService mementoService)
        {
            Argument.IsNotNull(() => studioState);
            Argument.IsNotNull(() => mementoService);

            this.StudioState = studioState;
            this.StudioState.ProjectPropertyChanged += this.OnStudioStateProjectPropertyChanged;
            this.mementoService = mementoService;
            this.isMainScript = true;
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObserverBase"/> class.
        /// </summary>
        /// <param name="tag">The tag, can be <c>null</c>.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        protected ObserverBase(object tag, IMementoService mementoService = null)
        {
            Tag = tag;

            if (mementoService == null)
            {
                var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
                mementoService = dependencyResolver.Resolve<IMementoService>();
            }

            _mementoService = mementoService;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObserverBase"/> class.
        /// </summary>
        /// <param name="tag">The tag, can be <c>null</c>.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        protected ObserverBase(object tag, IMementoService mementoService = null)
        {
            Tag = tag;

            if (mementoService == null)
            {
                var dependencyResolver = IoCConfiguration.DefaultDependencyResolver;
                mementoService = dependencyResolver.Resolve <IMementoService>();
            }

            _mementoService = mementoService;
        }
Exemplo n.º 7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectObserver"/> class.
        /// </summary>
        /// <param name="propertyChanged">The property changed.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyChanged"/> is <c>null</c>.</exception>
        public ObjectObserver(INotifyPropertyChanged propertyChanged, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("propertyChanged", propertyChanged);

            Log.Debug("Initializing ObjectObserver for type '{0}'", propertyChanged.GetType().Name);

            _weakEventListener = this.SubscribeToWeakPropertyChangedEvent(propertyChanged, OnPropertyChanged);

            InitializeDefaultValues(propertyChanged);

            Log.Debug("Initialized ObjectObserver for type '{0}'", propertyChanged.GetType().Name);
        }
Exemplo n.º 8
0
        public CommandsService(StudioStateModel model,
            ICommandManager commandManager,
            IMementoService mementoService,
            IMessageService messageService,
            IOpenFileService openFileService,
            IRecentlyUsedItemsService recentlyUsedItemsService,
            ISaveFileService saveFileService,
            IProcessService processService)
        {
            Argument.IsNotNull(() => model);
            Argument.IsNotNull(() => commandManager);
            Argument.IsNotNull(() => mementoService);
            Argument.IsNotNull(() => messageService);
            Argument.IsNotNull(() => openFileService);
            Argument.IsNotNull(() => recentlyUsedItemsService);
            Argument.IsNotNull(() => saveFileService);
            Argument.IsNotNull(() => processService);

            this.model = model;
            this.commandManager = commandManager;
            this.mementoService = mementoService;
            this.messageService = messageService;
            this.openFileService = openFileService;
            this.recentlyUsedItemsService = recentlyUsedItemsService;
            this.saveFileService = saveFileService;
            this.processService = processService;

            this.UndoCommand = new Command(this.Undo, this.CanUndo);
            this.RedoCommand = new Command(this.Redo, this.CanRedo);
            this.OpenProjectCommand = new Command(this.OpenProject, () => true);

            this.SaveProjectAsCommand = new Command(delegate { this.SaveAsProject(); }, () => true);
            this.SaveProjectCommand = new Command(delegate { this.SaveProject(); }, this.CanSave);

            this.OpenRecentlyUsedItemCommand = new Command<string>(this.OnOpenRecentlyUsedItemExecute);

            this.PinItemCommand = new Command<string>(this.PinItem);
            this.UnpinItemCommand = new Command<string>(this.UnpinItem);
            this.OpenInExplorerCommand = new Command<string>(this.OpenInExplorer);

            this.StartCommand = new Command(this.Start, this.CanStart);

            this.ExitCommand = new Command(this.Exit);

            commandManager.RegisterCommand("Script.Open", this.OpenProjectCommand);
            commandManager.RegisterCommand("Script.Save", this.SaveProjectCommand);
            commandManager.RegisterCommand("Script.SaveAs", this.SaveProjectAsCommand);
            commandManager.RegisterCommand("App.Exit", this.ExitCommand);

            this.model.ProjectPropertyChanged += this.OnProjectPropertyChanged;
        }
Exemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonViewModel"/> class.
        /// </summary>
        /// <param name="person">The person.</param>
        public PersonViewModel(Person person, IMementoService mementoService)
        {
            _mementoService = mementoService;

            Person = person ?? new Person();

            Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo);
            Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo);

            GenerateData      = new Command <object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute);
            ToggleCustomError = new Command <object>(OnToggleCustomErrorExecute);

            _mementoService.RegisterObject(this);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="PersonViewModel"/> class.
        /// </summary>
        /// <param name="person">The person.</param>
        public PersonViewModel(Person person, IMementoService mementoService)
        {
            _mementoService = mementoService;

            Person = person ?? new Person();

            Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo);
            Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo);

            GenerateData = new Command<object, object>(OnGenerateDataExecute, OnGenerateDataCanExecute);
            ToggleCustomError = new Command<object>(OnToggleCustomErrorExecute);

            _mementoService.RegisterObject(this);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectObserver"/> class.
        /// </summary>
        /// <param name="propertyChanged">The property changed.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyChanged"/> is <c>null</c>.</exception>
        public ObjectObserver(INotifyPropertyChanged propertyChanged, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("propertyChanged", propertyChanged);

            var propertyChangedType = propertyChanged.GetType();

            Log.Debug("Initializing ObjectObserver for type '{0}'", propertyChangedType.Name);

            _object = propertyChanged;
            _object.PropertyChanged += OnPropertyChanged;

            InitializeDefaultValues(propertyChanged);

            Log.Debug("Initialized ObjectObserver for type '{0}'", propertyChangedType.Name);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService, IMementoService mementoService)
        {
            _uiVisualizerService = uiVisualizerService;
            _messageService = messageService;
            _mementoService = mementoService;

            Add = new TaskCommand(OnAddExecuteAsync);
            Edit = new TaskCommand(OnEditExecuteAsync, OnEditCanExecute);
            Remove = new TaskCommand(OnRemoveExecuteAsync, OnRemoveCanExecute);

            Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo);
            Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo);

            PersonCollection = new ObservableCollection<Person> {new Person {Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik"}, new Person {Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket"}};

            _mementoService.RegisterCollection(PersonCollection);
        }
Exemplo n.º 13
0
        public MainViewModel(IMementoService mementoService)
            : base(mementoService)
        {
            Title = "Orc.Memento example";

            // disable state tracking of memento service while viewmodel will be initialized
            _mementoService.IsEnabled = false;

            UndoRedoEvents = new ObservableCollection <string>();
            Model          = new MyModel(_mementoService);

            // reactivate state tracking of memento service
            _mementoService.IsEnabled = true;

            Undo                 = new Command(OnUndoExecute, OnUndoCanExecute);
            Redo                 = new Command(OnRedoExecute, OnRedoCanExecute);
            Save                 = new Command(OnSaveExecute, OnSaveCanExecute);
            AddData              = new Command(OnAddDataExecute, OnAddDataCanExecute);
            AddSpecialData       = new Command <SpecialDataClass>(OnAddSpecialDataExecute, OnAddSpecialDataCanExecute);
            AddSpecialDataToRoot = new Command(OnAddSpecialDataToRootExecute, OnAddSpecialDataToRootCanExecute);
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="MainWindowViewModel"/> class.
        /// </summary>
        public MainWindowViewModel(IUIVisualizerService uiVisualizerService, IMessageService messageService, IMementoService mementoService)
        {
            _uiVisualizerService = uiVisualizerService;
            _messageService      = messageService;
            _mementoService      = mementoService;

            Add    = new Command(OnAddExecute);
            Edit   = new Command(OnEditExecute, OnEditCanExecute);
            Remove = new Command(OnRemoveExecute, OnRemoveCanExecute);

            Undo = new Command(() => _mementoService.Undo(), () => _mementoService.CanUndo);
            Redo = new Command(() => _mementoService.Redo(), () => _mementoService.CanRedo);

            PersonCollection = new ObservableCollection <Person> {
                new Person {
                    Gender = Gender.Male, FirstName = "Geert", MiddleName = "van", LastName = "Horrik"
                }, new Person {
                    Gender = Gender.Male, FirstName = "Fred", MiddleName = "", LastName = "Retteket"
                }
            };

            _mementoService.RegisterCollection(PersonCollection);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObserverBase"/> class.
        /// </summary>
        /// <param name="tag">The tag, can be <c>null</c>.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        protected ObserverBase(object tag, IMementoService mementoService = null)
        {
            Tag = tag;

            _mementoService = mementoService ?? ServiceLocator.Default.ResolveType <IMementoService>();
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionObserver"/> class.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
        public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("collection", collection);

            _collection = collection;
            _collection.CollectionChanged += OnCollectionChanged;
        }
Exemplo n.º 17
0
 public SpecialDataClass(IMementoService mementoService)
     : base(mementoService)
 {
 }
Exemplo n.º 18
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectObserver"/> class.
        /// </summary>
        /// <param name="propertyChanged">The property changed.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyChanged"/> is <c>null</c>.</exception>
        public ObjectObserver(INotifyPropertyChanged propertyChanged, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("propertyChanged", propertyChanged);

            var propertyChangedType = propertyChanged.GetType();

            Log.Debug("Initializing ObjectObserver for type '{0}'", propertyChangedType.Name);

            _object = propertyChanged;
            _object.PropertyChanged += OnPropertyChanged;

            InitializeDefaultValues(propertyChanged);

            Log.Debug("Initialized ObjectObserver for type '{0}'", propertyChangedType.Name);
        }
Exemplo n.º 19
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CollectionObserver"/> class.
        /// </summary>
        /// <param name="collection">The collection.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="collection"/> is <c>null</c>.</exception>
        public CollectionObserver(INotifyCollectionChanged collection, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("collection", collection);

            _weakEventListener = this.SubscribeToWeakCollectionChangedEvent(collection, OnCollectionChanged);
        }
Exemplo n.º 20
0
        public MementoModelBase(IMementoService mementoService)
        {
            _mementoService = mementoService;

            RegisterCallerForStateTracking(null);
        }
 public CustomDragDropEnabledViewModel(IMementoService mementoService)
 {
     _mementoService = mementoService;
 }
Exemplo n.º 22
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObserverBase"/> class.
        /// </summary>
        /// <param name="tag">The tag, can be <c>null</c>.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        protected ObserverBase(object tag, IMementoService mementoService = null)
        {
            Tag = tag;

            _mementoService = mementoService ?? ServiceLocator.Default.ResolveType<IMementoService>();
        }
Exemplo n.º 23
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ObjectObserver"/> class.
        /// </summary>
        /// <param name="propertyChanged">The property changed.</param>
        /// <param name="tag">The tag.</param>
        /// <param name="mementoService">The memento service. If <c>null</c>, the service will be retrieved from the <see cref="IServiceLocator"/>.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="propertyChanged"/> is <c>null</c>.</exception>
        public ObjectObserver(INotifyPropertyChanged propertyChanged, object tag = null, IMementoService mementoService = null)
            : base(tag, mementoService)
        {
            Argument.IsNotNull("propertyChanged", propertyChanged);

            Log.Debug("Initializing ObjectObserver for type '{0}'", propertyChanged.GetType().Name);

            _weakEventListener = this.SubscribeToWeakPropertyChangedEvent(propertyChanged, OnPropertyChanged);

            InitializeDefaultValues(propertyChanged);

            Log.Debug("Initialized ObjectObserver for type '{0}'", propertyChanged.GetType().Name);
        }
Exemplo n.º 24
0
 public MementoServiceTest()
 {
     m_savedPrincipal = Thread.CurrentPrincipal;
     m_mockRepository = new Mock <IMementoRepository>(MockBehavior.Strict);
     m_service        = new MementoService(m_mockRepository.Object);
 }
Exemplo n.º 25
0
        public MyModel(IMementoService mementoService)
            : base(mementoService)
        {
            Name     = "John";
            LastName = "Doe";

            Data           = new ObservableCollection <string>();
            DataCollection = new ObservableCollection <SpecialDataClass>
            {
                new SpecialDataClass(_mementoService)
                {
                    Data1      = "string data 1",
                    Data3      = "Teststring",
                    NestedData = new ObservableCollection <SpecialDataClass>
                    {
                        new SpecialDataClass(_mementoService)
                        {
                            Data1 = "string data 1_1", Data3 = "Teststring"
                        },
                        new SpecialDataClass(_mementoService)
                        {
                            Data1      = "string data 1_2",
                            Data3      = "Teststring",
                            NestedData = new ObservableCollection <SpecialDataClass>
                            {
                                new SpecialDataClass(_mementoService)
                                {
                                    Data1 = "1_2_1", Data3 = "Teststring"
                                },
                                new SpecialDataClass(_mementoService)
                                {
                                    Data1 = "1_2_3", Data3 = "Teststring"
                                },
                                new SpecialDataClass(_mementoService)
                                {
                                    Data1 = "1_2_3", Data3 = "Teststring"
                                },
                            }
                        },
                        new SpecialDataClass(_mementoService)
                        {
                            Data1 = "string data 1_3", Data3 = "Teststring"
                        },
                    }
                },
                new SpecialDataClass(_mementoService)
                {
                    Data1      = "string data 2",
                    NestedData = new ObservableCollection <SpecialDataClass>
                    {
                        new SpecialDataClass(_mementoService)
                        {
                            Data1 = "string data 2_1", Data3 = "Teststring"
                        },
                        new SpecialDataClass(_mementoService)
                        {
                            Data1 = "string data 2_2", Data3 = "Teststring"
                        },
                        new SpecialDataClass(_mementoService)
                        {
                            Data1 = "string data 2_3", Data3 = "Teststring"
                        },
                    }
                },
            };
        }