/// <summary> /// Default configuration for tracing writes to the debugger when the debugger is attached. /// </summary> internal void SetToDefaultConfiguration() { _traceWriterConfigs.Clear(); if (DebuggerFormatWriter.IsDebuggerActive()) { _traceWriterConfigs.Add(CreateDebugTraceWriterConfig()); } }
public void Clear(string xenkoVersion) { // Reload settings in case concurrent Game Studio instances are running. LoadFromSettings(); mostRecentlyUsedFiles.Clear(); // Save immediately SaveToSettings(xenkoVersion); }
public void TestClear() { ExpectCollectionRemove("item 1", "item 2", "item 3"); _set.Clear(); ExpectChangeCalls(1); _set.Clear(); ExpectChangeCalls(0); }
public void TestClear() { 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.Reset, e.Action); collectionChangedInvoked = true; }; set.Clear(); Assert.Empty(set); Assert.True(propertyChangedInvoked); Assert.True(collectionChangedInvoked); }
/// <summary> /// Clears the given Collection. /// </summary> public void ClearTest(ObservableSet <string> collection) { INotifyPropertyChanged collectionPropertyChanged = collection; collectionPropertyChanged.PropertyChanged += Collection_PropertyChanged; _expectedPropertyChanged = new[] { new PropertyNameExpected(COUNT), //new PropertyNameExpected(ITEMARRAY) }; collection.CollectionChanged += Collection_CollectionChanged; ExpectedCollectionChangedFired++; ExpectedAction = NotifyCollectionChangedAction.Reset; ExpectedNewItems = null; ExpectedNewStartingIndex = -1; ExpectedOldItems = null; ExpectedOldStartingIndex = -1; collection.Clear(); Assert.Equal(0, collection.Count); Assert.Equal(ExpectedCollectionChangedFired, NumCollectionChangedFired); foreach (var item in _expectedPropertyChanged) { Assert.True(item.IsFound, "The propertychanged event should have fired for" + item.Name + ", since we just cleared the collection"); } collection.CollectionChanged -= Collection_CollectionChanged; collectionPropertyChanged.PropertyChanged -= Collection_PropertyChanged; }
public void clear_should_raise_propertychanged() { bool eventWasRaisedForCount = false; bool eventWasRaisedForIsEmpty = false; var observableSet = new ObservableSet <int> { 1, 2, 3 }; observableSet.PropertyChanged += (sender, args) => { sender.Should().Be.EqualTo(observableSet); if (args.PropertyName == ISEMPTY_PROPERTY_NAME) { eventWasRaisedForIsEmpty = true; } if (args.PropertyName == COUNT_PROPERTY_NAME) { eventWasRaisedForCount = true; } }; observableSet.Clear(); eventWasRaisedForIsEmpty.Should().Be.True(); eventWasRaisedForCount.Should().Be.True(); }
public void clear_should_work() { var observableSet = new ObservableSet <int> { 1, 2, 3 }; observableSet.Clear(); observableSet.Count.Should().Be.EqualTo(0); }
/// <summary> /// Loads the data from the Install Log file. /// </summary> private void LoadPluginLog() { m_ostActivePlugins.Clear(); if (LogSerializer != null) { foreach (string strPlugin in LogSerializer.LoadPluginLog()) { m_ostActivePlugins.Add(ManagedPluginRegistry.GetPlugin(strPlugin)); } } }
/// <summary> /// Refreshes the list of elements that can be set as current selection. /// </summary> private void RefreshSelectableElements() { selectableElements.Clear(); var worldPosition = Controller.GetMousePositionInUI(); var elements = GetElementsAtPosition(ref worldPosition); if (elements != null) { selectableElements.AddRange(elements); } }
/// <summary> /// Commits the changes to the <see cref="ActivePluginLog"/>. /// </summary> public void Commit() { lock (EnlistedPluginLog.m_ostActivePlugins) { EnlistedPluginLog.m_ostActivePlugins.CollectionChanged -= MasterPlugins_CollectionChanged; foreach (Plugin plgNew in m_ostActivePlugins) { EnlistedPluginLog.m_ostActivePlugins.Add(plgNew); } for (Int32 i = EnlistedPluginLog.m_ostActivePlugins.Count - 1; i >= 0; i--) { if (!m_ostActivePlugins.Contains(EnlistedPluginLog.m_ostActivePlugins[i])) { EnlistedPluginLog.m_ostActivePlugins.RemoveAt(i); } } } EnlistedPluginLog.SavePluginLog(); m_booEnlisted = false; m_ostActivePlugins.Clear();; }
private void LoadFromSettings() { lock (SyncRoot) { // We load a copy of the profile in case concurrent Game Studio instances are running. var profileCopy = loadLatestProfile.Invoke(); var loadedList = settingsKey.GetValue(profileCopy, true); // Sort by descending timestamp loadedList.Sort((x, y) => - x.Timestamp.CompareTo(y.Timestamp)); mruList.Clear(); mruList.AddRange(loadedList.Where(IsDataValid)); } }
public void SetOperationsTest() { const int initialCount = 15; const int removeItems = 4; const int insertItems = 2; var items = new[] { 40, 63, 98, 20, 24, 76, 96, 53, 5, 11, 29, 12, 46, 59, 7, 45, 86, 91, 57, 95 }; var indexes = new[] { 6, 2, 5, 11, 0, 3, 13, 1 }; var originalSet = new HashSet <Person>(items.Take(initialCount).Select(x => new Person(x)), new PersonEqualityComparer()); var set = new ObservableSet <Person>(originalSet); var sorted = new SortedReadOnlyObservableList <Person>(set, (x, y) => x.Age.CompareTo(y.Age), new PersonEqualityComparer(), nameof(Person.Age)); Assert.AreEqual(initialCount, set.Count); Assert.AreEqual(initialCount, sorted.Count); Assert.IsTrue(items.Take(initialCount).Select(x => new Person(x)).OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer())); foreach (var person in indexes.Take(removeItems).Select(i => new Person(items[i]))) { set.Remove(person); } Assert.AreEqual(initialCount - removeItems, set.Count); Assert.AreEqual(initialCount - removeItems, sorted.Count); Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer())); foreach (var person in items.Skip(initialCount).Take(insertItems).Select(x => new Person(x))) { set.Add(person); } Assert.AreEqual(initialCount - removeItems + insertItems, set.Count); Assert.AreEqual(initialCount - removeItems + insertItems, sorted.Count); Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer())); foreach (var result in indexes.Skip(removeItems) .Zip(items.Skip(initialCount + insertItems), (i, x) => new { OldItem = new Person(items[i]), NewItem = new Person(x) })) { set.SymmetricExceptWith(new[] { result.OldItem, result.NewItem }); } Assert.AreEqual(initialCount - removeItems + insertItems, set.Count); Assert.AreEqual(initialCount - removeItems + insertItems, sorted.Count); Assert.IsTrue(originalSet.OrderBy(p => p.Age).SequenceEqual(sorted, new PersonEqualityComparer())); set.Clear(); Assert.AreEqual(0, set.Count); Assert.AreEqual(0, sorted.Count); }
public void TestClear() { ExpectCollectionChange(NotifyCollectionChangedAction.Remove, "item 1", "item 2", "item 3"); _set.Clear(); ExpectChangeCalls(1); _set.Clear(); ExpectChangeCalls(0); }
public static void ClearTest() { string[] anArray = { "one", "two", "three", "four" }; ObservableSet <string> col = new ObservableSet <string>(anArray); col.Clear(); Assert.Equal(0, col.Count); Assert.Empty(col); //AssertExtensions.Throws<ArgumentOutOfRangeException>("index", () => col.ToArray()[1]); //tests that the collectionChanged events are fired. CollectionAndPropertyChangedTester helper = new CollectionAndPropertyChangedTester(); col = new ObservableSet <string>(anArray); helper.ClearTest(col); }
public void clear_should_raise_collectionchanged() { bool eventWasRaised = false; var observableSet = new ObservableSet <int> { 1, 2, 3 }; observableSet.CollectionChanged += (sender, args) => { sender.Should().Be.EqualTo(observableSet); args.Action.Should().Be.EqualTo( NotifyCollectionChangedAction.Reset); eventWasRaised = true; }; observableSet.Clear(); eventWasRaised.Should().Be.True(); }
/// <summary> /// Loads the data from the Install Log file. /// </summary> private void LoadPluginLog() { if (m_ostActivePlugins != null) { m_ostActivePlugins.Clear(); } else { m_ostActivePlugins = new ObservableSet <Plugin>(PluginComparer.Filename); } if (LogSerializer != null) { foreach (string strPlugin in LogSerializer.LoadPluginLog()) { if (!String.IsNullOrEmpty(strPlugin)) { m_ostActivePlugins.Add(ManagedPluginRegistry.GetPlugin(strPlugin)); } } } }
private void InitializeLibraries() { factories.Clear(); // FIXME: only retrieve from current package and its dependencies var allLibraries = Session.AllPackages .GroupBy(p => p.Package.IsSystem) .ToDictionary(p => p.Key, p => p.SelectMany(x => x.Assets).OfType <UILibraryViewModel>()); // system libraries foreach (var sysLib in allLibraries[true]) { var asset = sysLib.Asset; factories.AddRange(asset.PublicUIElements.Select(x => new UIElementFromSystemLibrary(ServiceProvider, sysLib, x.Key))); } PanelFactories = factories.Where(f => f.Category == "Panel").OrderBy(f => f.Name).ToList(); // user libraries foreach (var userLib in allLibraries[false]) { RemoveLibrary(userLib); AddLibrary(userLib); } }
public void TestClear() { 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.Reset); collectionChangedInvoked = true; }; set.Clear(); Assert.AreEqual(set.Count, 0); Assert.True(propertyChangedInvoked); Assert.True(collectionChangedInvoked); }
public void Clear() { _logWriterConfigs.Clear(); }