public void ApplyEdits(params TestEdit[] edits)
        {
            if (edits.Length == 0)
            {
                return;
            }

            var args = new TextContentChangedEventArgs(edits[0].OldSnapshot, edits[edits.Length - 1].NewSnapshot, new EditOptions(), null);

            foreach (var edit in edits)
            {
                args.Changes.Add(new TestTextChange(edit.Change));
            }

            CurrentSnapshot = edits[edits.Length - 1].NewSnapshot;
            if (CurrentSnapshot is StringTextSnapshot testSnapshot)
            {
                testSnapshot.TextBuffer = this;
            }

            foreach (var changedEvent in AttachedChangedEvents)
            {
                changedEvent.Invoke(this, args);
            }

            PostChanged?.Invoke(this, null);

            ReadOnlyRegionsChanged?.Invoke(this, null);
            ChangedLowPriority?.Invoke(this, null);
            ChangedHighPriority?.Invoke(this, null);
            Changing?.Invoke(this, null);
        }
        private void UpdateSyncModes(SyncMode newModes)
        {
            if (_logger.IsTrace)
            {
                if (newModes != Current)
                {
                    string message = $"Changing state to {newModes}";
                    if (_logger.IsTrace)
                    {
                        _logger.Trace(message);
                    }
                }
            }

            SyncMode previous = Current;

            SyncModeChangedEventArgs args = new SyncModeChangedEventArgs(previous, Current);

            // Changing is invoked here so we can block until all the subsystems are ready to switch
            // for example when switching to Full sync we need to ensure that we safely transition
            // the beam sync DB and beam processor
            Preparing?.Invoke(this, args);
            Changing?.Invoke(this, args);
            Current = newModes;
            Changed?.Invoke(this, args);
        }
Example #3
0
        private void Rescan()
        {
            Task.Factory.StartNew(() =>
            {
                if (Changing != null)
                {
                    Changing.Invoke(this, EventArgs.Empty);
                }

                try {
                    InfoFormat("Rescanning...");
                    DoRoot();
                    InfoFormat("Done rescanning...");
                }
                catch (Exception ex) {
                    Error(ex);
                }


                if (Changed != null)
                {
                    Changed.Invoke(this, EventArgs.Empty);
                }
            }, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);
        }
Example #4
0
        private void RescanInternal()
        {
            if (!rescanning)
            {
                Debug("Rescanning disabled");
                return;
            }

            Task.Factory.StartNew(() =>
            {
                if (Changing != null)
                {
                    Changing.Invoke(this, EventArgs.Empty);
                }

                try {
                    NoticeFormat("Rescanning {0}...", FriendlyName);
                    DoRoot();
                    NoticeFormat("Done rescanning {0}...", FriendlyName);
                }
                catch (Exception ex) {
                    Error(ex);
                }


                if (Changed != null)
                {
                    Changed.Invoke(this, EventArgs.Empty);
                }
            },
                                  TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);
        }
Example #5
0
        /// <summary>
        ///     Unloads a Assambly From the Mef Container.
        ///     It does NOT unload it from the Domain
        /// </summary>
        /// <param name="assambly">Your Target assambly</param>
        public void FreeAssambly(Assembly assambly)
        {
            var assemblyName = assambly.Location;
            var all          = _aggregateCatalog.Catalogs.Where(s =>
            {
                var assemblyCatalog = s as AssemblyCatalog;
                if (assemblyCatalog != null)
                {
                    var assamblName = assemblyCatalog.Assembly;
                    var fn          = assamblName.Location;
                    return(assemblyName == fn);
                }
                return(false);
            }).Cast <AssemblyCatalog>();

            var assemblyCatalogs = all as AssemblyCatalog[] ?? all.ToArray();

            if (!assemblyCatalogs.Any())
            {
                ImportPool.AddImportFailMessage(assambly);
                return;
            }

            AssemblyCatalog first;

            if (assemblyCatalogs.Count() != 1)
            {
                var version = assemblyCatalogs.Max(s => AssemblyName.GetAssemblyName(s.Assembly.FullName).Version);
                first =
                    assemblyCatalogs.FirstOrDefault(
                        s => AssemblyName.GetAssemblyName(s.Assembly.FullName).Version == version);
            }
            else
            {
                first = assemblyCatalogs.FirstOrDefault();
            }

            if (first != null)
            {
                var parts = first.Parts;

                if (Changing != null)
                {
                    Changing.Invoke(this,
                                    new ComposablePartCatalogChangeEventArgs(new List <ComposablePartDefinition>(), parts,
                                                                             null));
                }

                _aggregateCatalog.Catalogs.Remove(first);

                ImportPool.AddSuccessExcludedMessage(assambly);

                if (Changed != null)
                {
                    Changed.Invoke(this,
                                   new ComposablePartCatalogChangeEventArgs(new List <ComposablePartDefinition>(), parts,
                                                                            null));
                }
            }
        }
Example #6
0
        public MainWindowViewModel()
        {
            Editor   = new NitraTextEditorViewModel(this);
            Settings = Settings.Default;

            var canFindSymbolDefinitions = this.WhenAny(v => v.CurrentSuite, v => v.CurrentFile,
                                                        (suite, test) => suite != null && test != null);

            FindSymbolDefinitions = ReactiveCommand.Create(canFindSymbolDefinitions);
            FindSymbolDefinitions.ThrownExceptions.Subscribe(e =>
                                                             StatusText = "GOTO definition failed!");
            FindSymbolDefinitions.Subscribe(OnFindSymbolDefinitions);

            FindSymbolReferences = ReactiveCommand.Create(canFindSymbolDefinitions);
            FindSymbolReferences.ThrownExceptions.Subscribe(e =>
                                                            StatusText = "Find all references definition failed!");
            FindSymbolReferences.Subscribe(OnFindSymbolReferences);

            Changing.Where(c => c.PropertyName == "Workspace")
            .Subscribe(_ => { if (Workspace != null)
                              {
                                  Workspace.Dispose();
                              }
                       });
        }
Example #7
0
        /// <summary>
        /// Raises the <see cref="Changing"/> event with the given parameters.
        /// </summary>
        /// <param name="index">The index where the change occurred, if applicable. <c>null</c> otherwise.</param>
        /// <param name="changeType">The type of change that occurred.</param>
        /// <param name="oldValue">The old value of this content.</param>
        /// <param name="newValue">The new value of this content.</param>
        protected void NotifyContentChanging(object index, ContentChangeType changeType, object oldValue, object newValue)
        {
            var args = new ContentChangeEventArgs(this, index, changeType, oldValue, newValue);

            PrepareChange?.Invoke(this, args);
            Changing?.Invoke(this, args);
        }
 public void Post([FromBody] Changing poop)
 {
     if (ModelState.IsValid)
     {
         changingRepository.Add(poop);
     }
 }
 public void Put(int id, [FromBody] Changing poop)
 {
     poop.poop_id = id;
     if (ModelState.IsValid)
     {
         changingRepository.Update(poop);
     }
 }
        void setupRx(IEnumerable <T> initialContents = null, IScheduler scheduler = null, double resetChangeThreshold = 0.3)
        {
            scheduler = scheduler ?? RxApp.DeferredScheduler;
            _inner    = _inner ?? new List <T>();

            _changing = new Subject <NotifyCollectionChangedEventArgs>();
            _changing.Where(_ => CollectionChanging != null && _suppressionRefCount == 0).Subscribe(x => CollectionChanging(this, x));

            _changed = new Subject <NotifyCollectionChangedEventArgs>();
            _changed.Where(_ => CollectionChanged != null && _suppressionRefCount == 0).Subscribe(x => CollectionChanged(this, x));

            ResetChangeThreshold = resetChangeThreshold;

            _beforeItemsAdded   = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsAdded         = new Lazy <Subject <T> >(() => new Subject <T>());
            _beforeItemsRemoved = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsRemoved       = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemChanging       = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());
            _itemChanged        = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());

            // NB: We have to do this instead of initializing _inner so that
            // Collection<T>'s accounting is correct
            foreach (var item in initialContents ?? Enumerable.Empty <T>())
            {
                Add(item);
            }

            // NB: ObservableCollection has a Secret Handshake with WPF where
            // they fire an INPC notification with the token "Item[]". Emulate
            // it here
            CollectionCountChanging.Subscribe(_ => {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs("Count"));
                }
            });

            CollectionCountChanged.Subscribe(_ => {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Count"));
                }
            });

            Changing.Subscribe(_ => {
                if (PropertyChanging != null)
                {
                    PropertyChanging(this, new PropertyChangingEventArgs("Item[]"));
                }
            });

            Changed.Subscribe(_ => {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs("Item[]"));
                }
            });
        }
        private void RaiseOnChangingSync(string key, object oldValue, object data)
        {
            var e = new ChangingEventArgs
            {
                Key      = key,
                OldValue = oldValue,
                NewValue = data
            };

            Changing?.Invoke(this, e);
        }
Example #12
0
 internal virtual void OnAddingObject()
 {
     if (Parent != null)
     {
         Parent.OnAddingObject();
     }
     if (Changing != null)
     {
         Changing.Invoke(this, null);
     }
 }
        private void RaiseOnChanging(string key, object data, out ChangingEventArgs e)
        {
            e = new ChangingEventArgs
            {
                Key      = key,
                OldValue = GetItem(key),
                NewValue = data
            };

            Changing?.Invoke(this, e);
        }
        private ChangingEventArgs RaiseOnChangingSync(string key, object data)
        {
            var e = new ChangingEventArgs
            {
                Key      = key,
                OldValue = ((ISyncLocalStorageService)this).GetItem <object>(key),
                NewValue = data
            };

            Changing?.Invoke(this, e);
            return(e);
        }
        public void Update(Changing poop)
        {
            var parameters = new { poop_id = poop.poop_id, poop_at = poop.poop_at, baby_id = poop.baby.baby_id };

            using (System.Data.IDbConnection dbConnection = Connection)
            {
                string sQuery = "UPDATE baby_changings SET"
                                + " poop_at=@poop_at, baby_id=@baby_id"
                                + " WHERE poop_id = @poop_id";
                dbConnection.Open();
                dbConnection.Query(sQuery, parameters);
            }
        }
Example #16
0
 public ValueTask SetItemAsync <T>(string key, T data)
 {
     Changing?.Invoke(this, new ChangingEventArgs()
     {
         Key = key, NewValue = data
     });
     dictionary[key] = data;
     Changed?.Invoke(this, new ChangedEventArgs()
     {
         Key = key, NewValue = data
     });
     return(ValueTask.CompletedTask);
 }
Example #17
0
        private ChangingEventArgs RaiseOnChangingSync(string key, object data)
        {
            var e = new ChangingEventArgs
            {
                Key      = key,
                OldValue = GetItemInternal <object>(key),
                NewValue = data
            };

            Changing?.Invoke(this, e);

            return(e);
        }
Example #18
0
        private async Task <ChangingEventArgs> RaiseOnChangingAsync(string key, object data)
        {
            var e = new ChangingEventArgs
            {
                Key      = key,
                OldValue = await GetItemAsync <object>(key),
                NewValue = data
            };

            Changing?.Invoke(this, e);

            return(e);
        }
        public void Add(Changing poop)
        {
            // peel what we need off of the incoming request object
            var parameters = new { poop_at = poop.poop_at, baby_id = poop.baby.baby_id };

            using (System.Data.IDbConnection dbConnection = Connection)
            {
                //feed in the parameters into the query directly instead of trying to reference the object.
                string sQuery = "INSERT INTO baby_changings (baby_id, poop_at)"
                                + " VALUES(@baby_id, @poop_at)";
                dbConnection.Open();
                dbConnection.Execute(sQuery, parameters);
            }
        }
Example #20
0
		/// <summary>
		///   Raises the Changing event. </summary>
		/// <param name="e">
		///   The arguments object associated with the Changing event. </param>
		/// <remarks>
		///   This method should be invoked prior to making a change to the profile so that the
		///   Changing event is raised, giving a chance to the handlers to prevent the change from
		///   happening (by setting e.Cancel to true). This method calls each individual handler 
		///   associated with the Changing event and checks the resulting e.Cancel flag.  
		///   If it's true, it stops and does not call of any remaining handlers since the change 
		///   needs to be prevented anyway. </remarks>
		/// <seealso cref="Changing" />
		/// <seealso cref="OnChanged" />
		protected virtual void OnChanging(ProfileChangingArgs e)
		{
			if (Changing == null)
				return;

			foreach (ProfileChangingHandler handler in Changing.GetInvocationList())
			{
				handler(this, e);
				
				// If a particular handler cancels the event, stop
				if (e.Cancel)
					break;
			}
		}
Example #21
0
        private void ContentChanging(object sender, ContentChangeEventArgs e)
        {
            var node = e.Content.OwnerNode as IGraphNode;

            if (node != null)
            {
                foreach (var child in GetAllChildNodes(node))
                {
                    child.Content.Changing -= ContentChanging;
                    child.Content.Changed  -= ContentChanged;
                }
            }

            Changing?.Invoke(sender, e);
        }
            public void ApplyEdit(TestEdit edit)
            {
                var args = new TextContentChangedEventArgs(edit.OldSnapshot, edit.NewSnapshot, new EditOptions(), null);

                args.Changes.Add(new TextChange(edit));
                Changed?.Invoke(this, args);

                ReadOnlyRegionsChanged?.Invoke(null, null);
                ChangedLowPriority?.Invoke(null, null);
                ChangedHighPriority?.Invoke(null, null);
                Changing?.Invoke(null, null);
                PostChanged?.Invoke(null, null);
                ContentTypeChanged?.Invoke(null, null);

                _currentSnapshot = edit.NewSnapshot;
            }
Example #23
0
        private void ApplyChange(TextSnapshotMock snapshot)
        {
            Changing?.Invoke(this, new TextContentChangingEventArgs(CurrentSnapshot, new object(), CancelAction));

            var before = CurrentSnapshot;

            CurrentSnapshot = snapshot;

            var args = new TextContentChangedEventArgs(before, CurrentSnapshot, EditOptions.None, new object());

            BeforeChanged?.Invoke(this, args);
            ChangedHighPriority?.Invoke(this, args);
            Changed?.Invoke(this, args);
            ChangedLowPriority?.Invoke(this, args);
            PostChanged?.Invoke(this, EventArgs.Empty);
        }
Example #24
0
        void UpdateList()
        {
            if (enableHacks)
            {
                foreach (var result in search.Results)
                {
                    if (itemsInList.Add(result.Item1))
                    {
                        Add(CreateCompletionData(result.Item1));
                    }
                }
            }
            else
            {
                Clear();
                foreach (var result in search.Results)
                {
                    Add(CreateCompletionData(result.Item1));
                }
            }

            //HACK: the completion window will not re-sort the list
            Sort(Comparer);
            IsSorted = true;

            //HACK: the completion list doesn't refilter after we update it
            //so we have to manually reset the filtering
            if (enableHacks && CompletionWindowManager.Wnd != null)
            {
                var window = completionWindowWindowField.GetValue(CompletionWindowManager.Wnd);
                var list   = listWindowListProp.GetValue(window);
                oldCompletionStringField.SetValue(list, null);
                filterWordsMeth.Invoke(CompletionWindowManager.Wnd, null);
            }

            bool wasChanging = false;

            IsChanging = search.RemainingFeeds.Count > 0;

            Changed?.Invoke(this, EventArgs.Empty);

            if (!wasChanging && IsChanging)
            {
                Changing?.Invoke(this, EventArgs.Empty);
            }
        }
Example #25
0
        /// <summary>
        ///   Raises the Changing event. </summary>
        /// <param name="e">
        ///   The arguments object associated with the Changing event. </param>
        /// <remarks>
        ///   This method should be invoked prior to making a change to the profile so that the
        ///   Changing event is raised, giving a chance to the handlers to prevent the change from
        ///   happening (by setting e.Cancel to true). This method calls each individual handler
        ///   associated with the Changing event and checks the resulting e.Cancel flag.
        ///   If it's true, it stops and does not call of any remaining handlers since the change
        ///   needs to be prevented anyway. </remarks>
        /// <seealso cref="Changing" />
        /// <seealso cref="OnChanged" />
        protected virtual void OnChanging(ProfileChangingArgs e)
        {
            if (Changing == null)
            {
                return;
            }

            foreach (ProfileChangingHandler handler in Changing.GetInvocationList())
            {
                handler(this, e);

                if (e.Cancel)
                {
                    break;
                }
            }
        }
        void setupRx(IEnumerable <T> initialContents = null, IScheduler scheduler = null, double resetChangeThreshold = 0.3)
        {
            if (rxObjectsSetup)
            {
                return;
            }

            scheduler = scheduler ?? RxApp.DeferredScheduler;
            _inner    = _inner ?? new List <T>();

            _changing = new Subject <NotifyCollectionChangedEventArgs>();
            _changing.Subscribe(raiseCollectionChanging);

            _changed = new Subject <NotifyCollectionChangedEventArgs>();
            _changed.Subscribe(raiseCollectionChanged);

            ResetChangeThreshold = resetChangeThreshold;

            _beforeItemsAdded   = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsAdded         = new Lazy <Subject <T> >(() => new Subject <T>());
            _beforeItemsRemoved = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsRemoved       = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemChanging       = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());
            _itemChanged        = new Lazy <Subject <IObservedChange <T, object> > >(() => new Subject <IObservedChange <T, object> >());
            _beforeItemsMoved   = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());
            _itemsMoved         = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());

            // NB: We have to do this instead of initializing _inner so that
            // Collection<T>'s accounting is correct
            foreach (var item in initialContents ?? Enumerable.Empty <T>())
            {
                Add(item);
            }

            // NB: ObservableCollection has a Secret Handshake with WPF where
            // they fire an INPC notification with the token "Item[]". Emulate
            // it here
            CollectionCountChanging.Select(x => new PropertyChangingEventArgs("Count")).Subscribe(this.raisePropertyChanging);
            CollectionCountChanged.Select(x => new PropertyChangedEventArgs("Count")).Subscribe(this.raisePropertyChanged);
            Changing.Select(x => new PropertyChangingEventArgs("Item[]")).Subscribe(this.raisePropertyChanging);
            Changed.Select(x => new PropertyChangedEventArgs("Item[]")).Subscribe(this.raisePropertyChanged);

            rxObjectsSetup = true;
        }
Example #27
0
        void setupRx(IEnumerable <T> initialContents = null, double resetChangeThreshold = 0.3, IScheduler scheduler = null)
        {
            scheduler = scheduler ?? RxApp.MainThreadScheduler;

            _inner = _inner ?? new List <T>();

            _changing = new Subject <NotifyCollectionChangedEventArgs>();
            _changing.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(raiseCollectionChanging);

            _changed = new Subject <NotifyCollectionChangedEventArgs>();
            _changed.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(raiseCollectionChanged);

            ResetChangeThreshold = resetChangeThreshold;

            _beforeItemsAdded   = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsAdded         = new Lazy <Subject <T> >(() => new Subject <T>());
            _beforeItemsRemoved = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemsRemoved       = new Lazy <Subject <T> >(() => new Subject <T>());
            _itemChanging       = new Lazy <ISubject <IReactivePropertyChangedEventArgs <T> > >(() => new ScheduledSubject <IReactivePropertyChangedEventArgs <T> >(scheduler));
            _itemChanged        = new Lazy <ISubject <IReactivePropertyChangedEventArgs <T> > >(() => new ScheduledSubject <IReactivePropertyChangedEventArgs <T> >(scheduler));
            _beforeItemsMoved   = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());
            _itemsMoved         = new Lazy <Subject <IMoveInfo <T> > >(() => new Subject <IMoveInfo <T> >());

            // NB: We have to do this instead of initializing _inner so that
            // Collection<T>'s accounting is correct
            foreach (var item in initialContents ?? Enumerable.Empty <T>())
            {
                Add(item);
            }

            // NB: ObservableCollection has a Secret Handshake with WPF where
            // they fire an INPC notification with the token "Item[]". Emulate
            // it here
            CountChanging.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging("Count"));

            CountChanged.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("Count"));

            IsEmptyChanged.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("IsEmpty"));

            Changing.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanging("Item[]"));

            Changed.Where(_ => this.areChangeNotificationsEnabled()).Subscribe(_ => this.RaisePropertyChanged("Item[]"));
        }
Example #28
0
        private void RescanInternal()
        {
            lock (this)
            {
                if (!rescanning)
                {
                    Debug("Rescanning disabled");
                    return;
                }

                if (isRescanning)
                {
                    Debug("Already rescanning");
                }
                isRescanning = true;
            }
            Task.Factory.StartNew(() =>
            {
                try
                {
                    Changing?.Invoke(this, EventArgs.Empty);

                    try
                    {
                        NoticeFormat("Rescanning {0}...", FriendlyName);
                        DoRoot();
                        NoticeFormat("Done rescanning {0}...", FriendlyName);
                    }
                    catch (Exception ex)
                    {
                        Error(ex);
                    }
                    Changed?.Invoke(this, EventArgs.Empty);
                }
                finally
                {
                    lock (this)
                    {
                        isRescanning = false;
                    }
                }
            }, TaskCreationOptions.AttachedToParent | TaskCreationOptions.LongRunning);
        }
Example #29
0
        void UpdateSearch(string searchString)
        {
            if (oldSearchString != null && !ShouldUpdate(searchString, oldSearchString))
            {
                return;
            }
            oldSearchString = searchString;

            var newSearch = CreateSearch(searchString);

            if (search != null)
            {
                search.Cancel();
                search.Updated -= HandleSearchUpdated;
            }
            search          = newSearch;
            search.Updated += HandleSearchUpdated;

            Changing?.Invoke(this, EventArgs.Empty);
            UpdateList();
        }
        /// <summary>
        ///
        /// </summary>
        public ReactiveValidatedObject()
        {
            Changing.Subscribe(x =>
            {
                if (x.Sender != this)
                {
                    return;
                }

                if (_validationCache.ContainsKey(x.PropertyName))
                {
                    _validationCache.Remove(x.PropertyName);
                }
            });

            _validatedPropertyCount = new Lazy <int>(() =>
            {
                lock (allValidatedProperties)
                {
                    return(allValidatedProperties.Get(GetType()).Count);
                }
            });
        }