public void TestInsert() { var list = new List <string> { "aaa", "bbb", "ccc" }; var set = new ObservableSet <string>(list); Assert.Equal(set.Count, list.Count); bool propertyChangedInvoked = false; bool collectionChangedInvoked = false; set.PropertyChanged += (sender, e) => { Assert.Equal(nameof(ObservableSet <string> .Count), e.PropertyName); propertyChangedInvoked = true; }; set.CollectionChanged += (sender, e) => { Assert.Equal(NotifyCollectionChangedAction.Add, e.Action); Assert.Equal(1, e.NewStartingIndex); Assert.NotNull(e.NewItems); Assert.Equal(1, e.NewItems.Count); Assert.Equal("ddd", e.NewItems[0]); collectionChangedInvoked = true; }; set.Insert(1, "ddd"); Assert.Equal(4, set.Count); Assert.Equal("aaa", set[0]); Assert.Equal("ddd", set[1]); Assert.Equal("bbb", set[2]); Assert.Equal("ccc", set[3]); Assert.True(propertyChangedInvoked); Assert.True(collectionChangedInvoked); }
public void AddFile(UFile filePath) { // Reload settings in case concurrent Game Studio instances are running. LoadFromSettings(); // Remove it if it was already in the list mostRecentlyUsedFiles.RemoveWhere(x => string.Equals(x.FilePath, filePath, StringComparison.OrdinalIgnoreCase)); // Add it on top of the list mostRecentlyUsedFiles.Insert(0, new MostRecentlyUsedFile(filePath)); // Save immediately SaveToSettings(); }
private MRUAdditionalData GetOrCreateDataPrivate(UFile filePath, bool createIfNotExist = true) { var data = mruList.FirstOrDefault(m => string.Equals(m?.FilePath, filePath, StringComparison.OrdinalIgnoreCase)); if (data == null && createIfNotExist) { data = new MRUAdditionalData(filePath) { DockingLayout = GameStudioInternalSettings.DefaultLayout, DockingLayoutEditors = GameStudioInternalSettings.DefaultEditorLayout, }; mruList.Insert(0, data); } return(data); }
public void TestInsert() { var list = new List<string> { "aaa", "bbb", "ccc" }; var set = new ObservableSet<string>(list); Assert.AreEqual(set.Count, list.Count); bool propertyChangedInvoked = false; bool collectionChangedInvoked = false; set.PropertyChanged += (sender, e) => { Assert.AreEqual(e.PropertyName, nameof(ObservableSet<string>.Count)); propertyChangedInvoked = true; }; set.CollectionChanged += (sender, e) => { Assert.AreEqual(e.Action, NotifyCollectionChangedAction.Add); Assert.AreEqual(e.NewStartingIndex, 1); Assert.NotNull(e.NewItems); Assert.AreEqual(e.NewItems.Count, 1); Assert.AreEqual(e.NewItems[0], "ddd"); collectionChangedInvoked = true; }; set.Insert(1, "ddd"); Assert.AreEqual(set.Count, 4); Assert.AreEqual(set[0], "aaa"); Assert.AreEqual(set[1], "ddd"); Assert.AreEqual(set[2], "bbb"); Assert.AreEqual(set[3], "ccc"); Assert.True(propertyChangedInvoked); Assert.True(collectionChangedInvoked); }