public void CanSetList() { characters.Set(new[] { interestedCharacter.Name }, ListKind.Interested); ShouldBeOnOfflineListOf(ListKind.Interested, interestedCharacter); SignOnAllTestCharacters(); ShouldBeOnList(ListKind.Interested, interestedCharacter); }
public void UpdatePendingRequests() { var worker = new BackgroundWorker(); worker.DoWork += (s, e) => { var result = DoApiAction(Constants.UrlConstants.IncomingFriendRequests); var relevant = result .Where(x => x.Destination.Equals(selectedCharacter, StringComparison.OrdinalIgnoreCase)) .ToList(); requestsReceived.Clear(); relevant.Each(x => requestsReceived.Add(x.Source, x.Id)); characterManager.Set(relevant.Select(x => x.Source), ListKind.FriendRequestReceived); }; worker.RunWorkerAsync(); }
/// <summary> /// Updates the application settings from file /// </summary> public static void ReadApplicationSettingsFromXml(string currentCharacter, ICharacterManager cm) { Log("Reading global settings"); MakeGlobalSettingsFileIfNotExist(currentCharacter); var type = typeof(ApplicationSettings); var propertyList = type.GetProperties(); var path = StringExtensions.MakeSafeFolderPath(currentCharacter, "Global", "Global"); path = Path.Combine(path, SettingsFileName); // this clusterfuck is why you don't have static classes for settings try { using (var fs = new FileStream(path, FileMode.Open, FileAccess.Read)) { var workingElement = XElement.Load(fs); foreach (var element in workingElement.Descendants()) { var element1 = element; foreach (var property in propertyList .Where( property => string.Equals(property.Name, element1.Name.ToString(), StringComparison.Ordinal)) .Where(property => !string.IsNullOrWhiteSpace(element1.Value))) { if (!element.HasElements) { try { var setter = property.PropertyType.IsEnum ? Enum.Parse(property.PropertyType, element.Value) : Convert.ChangeType(element.Value, property.PropertyType); property.SetValue(null, setter, null); } catch { } continue; } var collection = ApplicationSettings.SavedChannels; if (property.Name.Equals("recentChannels", StringComparison.OrdinalIgnoreCase)) { collection = ApplicationSettings.RecentChannels; } else if (property.Name.Equals("recentCharacters", StringComparison.OrdinalIgnoreCase)) { collection = ApplicationSettings.RecentCharacters; } if (property.Name.Equals("interested", StringComparison.OrdinalIgnoreCase)) { cm.Set(element.Elements().Select(x => x.Value), ListKind.Interested); } else if (property.Name.Equals("notinterested", StringComparison.OrdinalIgnoreCase)) { cm.Set(element.Elements().Select(x => x.Value), ListKind.NotInterested); } else if (property.Name.Equals("ignoreupdates", StringComparison.OrdinalIgnoreCase)) { cm.Set(element.Elements().Select(x => x.Value), ListKind.IgnoreUpdates); } else { collection.Clear(); foreach (var item in element.Elements()) { collection.Add(item.Value); } } } } } Log("Global settings read"); } catch (InvalidOperationException) { } }