/// <inheritdoc /> async Task <IDictionaryRange <int, MapName> > IRepository <int, MapName> .FindAllAsync(CancellationToken cancellationToken) { IMapNameRepository self = this; var request = new MapNameRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <ICollection <MapNameDTO> >(request, cancellationToken).ConfigureAwait(false); if (response.Content == null) { return(new DictionaryRange <int, MapName>(0)); } var values = response.Content.Select(value => this.mapNameConverter.Convert(value, null)).ToList(); var mapNames = new DictionaryRange <int, MapName>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var mapName in values) { mapName.Culture = request.Culture; mapNames.Add(mapName.MapId, mapName); } return(mapNames); }
private IDictionaryRange <string, Asset> ConvertAsyncResponse(Task <IResponse <IDictionary <string, FileDataContract> > > task) { var response = task.Result; var content = response.Content; if (content == null) { return(new DictionaryRange <string, Asset>(0)); } var values = new DictionaryRange <string, Asset>(content.Count) { SubtotalCount = content.Count, TotalCount = content.Count }; foreach (var kvp in content) { var value = this.converterForAsset.Convert(kvp.Value, null); if (value == null) { continue; } value.Identifier = kvp.Key; values.Add(value.Identifier, value); } return(values); }
/// <inheritdoc /> Task <IDictionaryRange <int, ColorPalette> > IRepository <int, ColorPalette> .FindAllAsync(CancellationToken cancellationToken) { IColorRepository self = this; var request = new ColorRequest { Culture = self.Culture }; return(this.serviceClient.SendAsync <ColorCollectionDataContract>(request, cancellationToken).ContinueWith <IDictionaryRange <int, ColorPalette> >( task => { var response = task.Result; if (response.Content == null || response.Content.Colors == null) { return new DictionaryRange <int, ColorPalette>(0); } var values = this.converterForColorPaletteCollection.Convert(response.Content, null); var colorPalettes = new DictionaryRange <int, ColorPalette>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var colorPalette in values) { colorPalette.Culture = request.Culture; colorPalettes.Add(colorPalette.ColorId, colorPalette); } return colorPalettes; }, cancellationToken)); }
/// <inheritdoc /> IDictionaryRange <TKey, TValue> IConverter <IResponse <ICollection <TDTO> >, IDictionaryRange <TKey, TValue> > .Convert(IResponse <ICollection <TDTO> > value, object state) { if (value == null) { return(new DictionaryRange <TKey, TValue>(0)); } var dataContracts = value.Content; if (dataContracts == null) { return(new DictionaryRange <TKey, TValue>(0)); } var range = new DictionaryRange <TKey, TValue>(dataContracts.Count) { SubtotalCount = value.GetResultCount(), TotalCount = value.GetResultTotal() }; foreach (var item in dataContracts.Select(dataContract => this.dataContractConverter.Convert(dataContract, value))) { range.Add(this.keySelector(item), item); } return(range); }
/// <inheritdoc /> async Task <IDictionaryRange <string, Objective> > IRepository <string, Objective> .FindAllAsync(ICollection <string> identifiers, CancellationToken cancellationToken) { IObjectiveRepository self = this; var request = new ObjectiveBulkRequest { Culture = self.Culture, Identifiers = identifiers }; var response = await this.serviceClient.SendAsync <ICollection <ObjectiveDTO> >(request); if (response.Content == null) { return(new DictionaryRange <string, Objective>(0)); } var values = response.Content.Select(value => this.objectiveConverter.Convert(value, null)).ToList(); var objectives = new DictionaryRange <string, Objective>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var objective in values) { objective.Culture = request.Culture; objectives.Add(objective.ObjectiveId, objective); } return(objectives); }
private IDictionaryRange <int, World> ConvertAsyncResponse(Task <IResponse <ICollection <WorldDataContract> > > task, CultureInfo culture) { Debug.Assert(task != null, "task != null"); var response = task.Result; var dataContracts = response.Content; if (dataContracts == null) { return(new DictionaryRange <int, World>(0)); } var worlds = new DictionaryRange <int, World>(dataContracts.Count) { SubtotalCount = dataContracts.Count, TotalCount = dataContracts.Count }; foreach (var world in this.converterForWorldCollection.Convert(dataContracts, null)) { world.Culture = culture; worlds.Add(world.WorldId, world); } return(worlds); }
/// <inheritdoc /> async Task <IDictionaryRange <int, World> > IRepository <int, World> .FindAllAsync(CancellationToken cancellationToken) { IWorldRepository self = this; var request = new WorldNameRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <ICollection <WorldDTO> >(request, cancellationToken).ConfigureAwait(false); if (response.Content == null) { return(new DictionaryRange <int, World>(0)); } var worlds = new DictionaryRange <int, World>(response.Content.Count) { SubtotalCount = response.Content.Count, TotalCount = response.Content.Count }; foreach (var world in this.worldCollectionConverter.Convert(response.Content, response)) { world.Culture = request.Culture; worlds.Add(world.WorldId, world); } return(worlds); }
/// <inheritdoc /> IDictionaryRange <string, Asset> IRepository <string, Asset> .FindAll() { var request = new FileRequest(); var response = this.serviceClient.Send <IDictionary <string, FileDTO> >(request); var content = response.Content; if (content == null) { return(new DictionaryRange <string, Asset>(0)); } var values = new DictionaryRange <string, Asset>(content.Count) { SubtotalCount = content.Count, TotalCount = content.Count }; foreach (var kvp in content) { var value = this.assetConverter.Convert(kvp.Value, null); if (value == null) { continue; } value.Identifier = kvp.Key; values.Add(value.Identifier, value); } return(values); }
/// <inheritdoc /> IDictionaryRange <int, World> IRepository <int, World> .FindAll() { IWorldRepository self = this; var request = new WorldNameRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ICollection <WorldDTO> >(request); if (response.Content == null) { return(new DictionaryRange <int, World>(0)); } var worlds = new DictionaryRange <int, World>(response.Content.Count) { SubtotalCount = response.Content.Count, TotalCount = response.Content.Count }; foreach (var world in this.worldCollectionConverter.Convert(response.Content, null)) { world.Culture = request.Culture; worlds.Add(world.WorldId, world); } return(worlds); }
/// <inheritdoc /> IDictionaryRange <int, MapName> IRepository <int, MapName> .FindAll() { IMapNameRepository self = this; var request = new MapNameRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ICollection <MapNameDataContract> >(request); if (response.Content == null) { return(new DictionaryRange <int, MapName>(0)); } var values = response.Content.Select(value => this.converterForMapName.Convert(value, null)).ToList(); var mapNames = new DictionaryRange <int, MapName>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var mapName in values) { mapName.Culture = request.Culture; mapNames.Add(mapName.MapId, mapName); } return(mapNames); }
/// <inheritdoc /> IDictionaryRange <int, ColorPalette> IRepository <int, ColorPalette> .FindAll() { IColorRepository self = this; var request = new ColorRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ColorCollectionDataContract>(request); if (response.Content == null || response.Content.Colors == null) { return(new DictionaryRange <int, ColorPalette>(0)); } var values = this.converterForColorPaletteCollection.Convert(response.Content, null); var colorPalettes = new DictionaryRange <int, ColorPalette>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var colorPalette in values) { colorPalette.Culture = request.Culture; colorPalettes.Add(colorPalette.ColorId, colorPalette); } return(colorPalettes); }
/// <inheritdoc /> async Task <IDictionaryRange <int, Continent> > IRepository <int, Continent> .FindAllAsync(CancellationToken cancellationToken) { IContinentRepository self = this; var request = new ContinentRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <ContinentCollectionDTO>(request, cancellationToken).ConfigureAwait(false); if (response.Content == null || response.Content.Continents == null) { return(new DictionaryRange <int, Continent>(0)); } var values = this.continentCollectionConverter.Convert(response.Content, null); var continents = new DictionaryRange <int, Continent>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var continent in values) { continent.Culture = request.Culture; continents.Add(continent.ContinentId, continent); } return(continents); }
/// <inheritdoc /> IDictionaryRange <int, Map> IRepository <int, Map> .FindAll() { IMapRepository self = this; var request = new MapRequest { Culture = self.Culture }; var response = this.serviceClient.Send <MapCollectionDTO>(request); if (response.Content == null || response.Content.Maps == null) { return(new DictionaryRange <int, Map>(0)); } var values = this.mapCollectionConverter.Convert(response.Content, null); var maps = new DictionaryRange <int, Map>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var map in values) { map.Culture = request.Culture; maps.Add(map.MapId, map); } return(maps); }
/// <inheritdoc /> async Task <IDictionaryRange <int, Map> > IRepository <int, Map> .FindAllAsync(CancellationToken cancellationToken) { IMapRepository self = this; var request = new MapRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <MapCollectionDTO>(request, cancellationToken).ConfigureAwait(false); if (response.Content == null || response.Content.Maps == null) { return(null); } var values = this.mapCollectionConverter.Convert(response.Content, null); var maps = new DictionaryRange <int, Map>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var map in values) { map.Culture = request.Culture; maps.Add(map.MapId, map); } return(maps); }
/// <inheritdoc /> async Task <IDictionaryRange <Guid, DynamicEventName> > IRepository <Guid, DynamicEventName> .FindAllAsync(CancellationToken cancellationToken) { IEventNameRepository self = this; var request = new DynamicEventNameRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <ICollection <EventNameDTO> >(request, cancellationToken).ConfigureAwait(false); if (response.Content == null) { return(new DictionaryRange <Guid, DynamicEventName>(0)); } var dynamicEventNames = new DictionaryRange <Guid, DynamicEventName>(response.Content.Count) { SubtotalCount = response.Content.Count, TotalCount = response.Content.Count }; foreach (var dynamicEventName in this.dynamicEventNameCollectionConverter.Convert(response.Content, null)) { dynamicEventName.Culture = request.Culture; dynamicEventNames.Add(dynamicEventName.EventId, dynamicEventName); } return(dynamicEventNames); }
/// <inheritdoc /> IDictionaryRange <Guid, DynamicEventName> IRepository <Guid, DynamicEventName> .FindAll() { IEventNameRepository self = this; var request = new DynamicEventNameRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ICollection <EventNameDTO> >(request); if (response.Content == null) { return(new DictionaryRange <Guid, DynamicEventName>(0)); } var dynamicEventNames = new DictionaryRange <Guid, DynamicEventName>(response.Content.Count) { SubtotalCount = response.Content.Count, TotalCount = response.Content.Count }; foreach (var dynamicEventName in this.dynamicEventNameCollectionConverter.Convert(response.Content, null)) { dynamicEventName.Culture = request.Culture; dynamicEventNames.Add(dynamicEventName.EventId, dynamicEventName); } return(dynamicEventNames); }
/// <inheritdoc /> Task <IDictionaryRange <int, MapName> > IRepository <int, MapName> .FindAllAsync(CancellationToken cancellationToken) { IMapNameRepository self = this; var request = new MapNameRequest { Culture = self.Culture }; return(this.serviceClient.SendAsync <ICollection <MapNameDataContract> >(request, cancellationToken).ContinueWith <IDictionaryRange <int, MapName> >( task => { var response = task.Result; if (response.Content == null) { return new DictionaryRange <int, MapName>(0); } var values = response.Content.Select(value => this.converterForMapName.Convert(value, null)).ToList(); var mapNames = new DictionaryRange <int, MapName>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var mapName in values) { mapName.Culture = request.Culture; mapNames.Add(mapName.MapId, mapName); } return mapNames; }, cancellationToken)); }
/// <inheritdoc /> IDictionaryRange <int, Continent> IRepository <int, Continent> .FindAll() { IContinentRepository self = this; var request = new ContinentRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ContinentCollectionDTO>(request); if (response.Content == null || response.Content.Continents == null) { return(new DictionaryRange <int, Continent>(0)); } var values = this.continentCollectionConverter.Convert(response.Content, null); var continents = new DictionaryRange <int, Continent>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var continent in values) { continent.Culture = request.Culture; continents.Add(continent.ContinentId, continent); } return(continents); }
/// <inheritdoc /> Task <IDictionaryRange <int, Map> > IRepository <int, Map> .FindAllAsync(CancellationToken cancellationToken) { IMapRepository self = this; var request = new MapRequest { Culture = self.Culture }; return(this.serviceClient.SendAsync <MapCollectionDataContract>(request, cancellationToken).ContinueWith <IDictionaryRange <int, Map> >( task => { var response = task.Result; if (response.Content == null || response.Content.Maps == null) { return null; } var values = this.converterForMapCollection.Convert(response.Content, null); var maps = new DictionaryRange <int, Map>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var map in values) { map.Culture = request.Culture; maps.Add(map.MapId, map); } return maps; }, cancellationToken)); }
/// <inheritdoc /> async Task <IDictionaryRange <string, Asset> > IRepository <string, Asset> .FindAllAsync(CancellationToken cancellationToken) { var request = new FileRequest(); var response = await this.serviceClient.SendAsync <IDictionary <string, FileDTO> >(request, cancellationToken).ConfigureAwait(false); if (response.Content == null) { return(new DictionaryRange <string, Asset>(0)); } var values = new DictionaryRange <string, Asset>(response.Content.Count) { SubtotalCount = response.Content.Count, TotalCount = response.Content.Count }; foreach (var kvp in response.Content) { var value = this.assetConverter.Convert(kvp.Value, null); if (value == null) { continue; } value.Identifier = kvp.Key; values.Add(value.Identifier, value); } return(values); }
/// <inheritdoc /> IDictionaryRange <int, ObjectiveName> IRepository <int, ObjectiveName> .FindAll() { IObjectiveNameRepository self = this; var request = new ObjectiveNameRequest { Culture = self.Culture }; var response = this.serviceClient.Send <ICollection <ObjectiveNameDTO> >(request); if (response.Content == null) { return(new DictionaryRange <int, ObjectiveName>(0)); } var values = response.Content.Select(value => this.objectiveNameConverter.Convert(value, null)).ToList(); var objectiveNames = new DictionaryRange <int, ObjectiveName>(values.Count) { SubtotalCount = values.Count, TotalCount = values.Count }; foreach (var objectiveName in values) { objectiveName.Culture = request.Culture; objectiveNames.Add(objectiveName.ObjectiveId, objectiveName); } return(objectiveNames); }
/// <summary>Saves the settings to the repository.</summary> public void SaveSettings() { var settings = new DictionaryRange <string, object> { { "SkyrimPath", this.SkyrimPath }, { "ModOrganizerPath", this.OrganizerPath } }; this.settingsRepository.Update(settings); }
/// <summary>Saves the selected solution to the solution repository.</summary> public void SaveSolution() { // Create a solution object with the information attainable from this view model. Solution sln = new Solution { Path = this.SolutionPath, Name = this.SolutionName, Version = this.Version }; // Get the configurations the solution currently has IList <CompileConfiguration> compileConfigs = new List <CompileConfiguration>(this.Configurations.Where(config => !Equals(config, Constants.EditCompileConfiguration))); sln.CompileConfigurations = compileConfigs; // Refresh the information on the currently selected configuration and set the name. CompileConfiguration selectedConfig = this.GenerateConfigurationDetails(); selectedConfig.Name = this.SelectedConfiguration; sln.SelectedConfiguration = this.SelectedConfiguration; // Now we need to pass the solution to the repository. Since it only accepts DictionaryRanges // we need to wrap the solution. IDictionaryRange <string, Solution> solutions = new DictionaryRange <string, Solution>(); solutions.Add(this.SolutionName, sln); // We also need to check if the solution name changed and handle it properly. if (this.oldSolutionName != this.SolutionName) { this.solutionRepository.Delete(new List <string> { this.oldSolutionName }); this.solutionRepository.Create(solutions); this.oldSolutionName = sln.Name; } else { this.solutionRepository.Update(solutions); } // Refresh the view models properties this.Configurations = new ObservableCollection <CompileConfiguration>(sln.CompileConfigurations) { Constants.EditCompileConfiguration }; // Reset the selected configuration this.SelectedConfiguration = sln.SelectedConfiguration; }
/// <inheritdoc /> IDictionaryRange <Guid, DynamicEvent> IRepository <Guid, DynamicEvent> .FindAll() { IEventRepository self = this; var request = new DynamicEventDetailsRequest { Culture = self.Culture }; var response = this.serviceClient.Send <EventCollectionDataContract>(request); var eventCollectionDataContract = response.Content; if (eventCollectionDataContract == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var eventDataContracts = eventCollectionDataContract.Events; if (eventDataContracts == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var dynamicEvents = this.converterForDynamicEventCollection.Convert(eventCollectionDataContract, null); if (dynamicEvents == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var events = new DictionaryRange <Guid, DynamicEvent>(dynamicEvents.Count) { SubtotalCount = dynamicEvents.Count, TotalCount = dynamicEvents.Count }; foreach (var dynamicEvent in dynamicEvents) { dynamicEvent.Culture = request.Culture; events.Add(dynamicEvent.EventId, dynamicEvent); } return(events); }
/// <inheritdoc /> async Task <IDictionaryRange <Guid, DynamicEvent> > IRepository <Guid, DynamicEvent> .FindAllAsync(CancellationToken cancellationToken) { IEventRepository self = this; var request = new DynamicEventDetailsRequest { Culture = self.Culture }; var response = await this.serviceClient.SendAsync <EventCollectionDTO>(request, cancellationToken).ConfigureAwait(false); if (response.Content == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } if (response.Content.Events == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var dynamicEvents = this.dynamicEventCollectionConverter.Convert(response.Content, null); if (dynamicEvents == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var events = new DictionaryRange <Guid, DynamicEvent>(dynamicEvents.Count) { SubtotalCount = dynamicEvents.Count, TotalCount = dynamicEvents.Count }; foreach (var dynamicEvent in dynamicEvents) { dynamicEvent.Culture = request.Culture; events.Add(dynamicEvent.EventId, dynamicEvent); } return(events); }
private IDictionaryRange <Guid, DynamicEvent> ConvertAsyncResponse(Task <IResponse <EventCollectionDataContract> > task, CultureInfo culture) { var response = task.Result; var eventCollectionDataContract = response.Content; if (eventCollectionDataContract == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var eventDataContracts = eventCollectionDataContract.Events; if (eventDataContracts == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var dynamicEvents = this.converterForDynamicEventCollection.Convert(eventCollectionDataContract, null); if (dynamicEvents == null) { return(new DictionaryRange <Guid, DynamicEvent>(0)); } var events = new DictionaryRange <Guid, DynamicEvent>(dynamicEvents.Count) { SubtotalCount = dynamicEvents.Count, TotalCount = dynamicEvents.Count }; foreach (var dynamicEvent in dynamicEvents) { dynamicEvent.Culture = culture; events.Add(dynamicEvent.EventId, dynamicEvent); } return(events); }
private IDictionaryRange <Guid, DynamicEventName> ConvertAsyncResponse(Task <IResponse <ICollection <EventNameDataContract> > > task, CultureInfo culture) { var response = task.Result; var eventNameDataContracts = response.Content; if (eventNameDataContracts == null) { return(new DictionaryRange <Guid, DynamicEventName>(0)); } var dynamicEventNames = new DictionaryRange <Guid, DynamicEventName>(eventNameDataContracts.Count) { SubtotalCount = eventNameDataContracts.Count, TotalCount = eventNameDataContracts.Count }; foreach (var dynamicEventName in this.converterForDynamicEventNameCollection.Convert(eventNameDataContracts, null)) { dynamicEventName.Culture = culture; dynamicEventNames.Add(dynamicEventName.EventId, dynamicEventName); } return(dynamicEventNames); }
/// <summary>Saves the settings to the repository.</summary> public void SaveSettings() { var settings = new DictionaryRange<string, object> { { "SkyrimPath", this.SkyrimPath }, { "ModOrganizerPath", this.OrganizerPath } }; this.settingsRepository.Update(settings); }