//private void GenerateItemKeys<TJsonResponse>( // TJsonResponse jsonResponse, // string attribute, // string region, // bool useNameForKeyGeneration = true, // bool useBaseTypeForKeyGeneration = false) where TJsonResponse : PoeNinjaDataService.ItemJsonResponse //{ // AddToDictionary(new RegionMarker { Description = " #region " + region + " Keys" }); // foreach(var line in jsonResponse.Lines) // { // AddToDictionary(line, attribute); // } // AddToDictionary(new RegionMarker { Description = " #endregion " + region + " Keys" }); //} private string FormatStringToKey( PoeNinjaDataService.ItemJsonResponse.Line line, GenerateItemKeysSetting settings) { return FormatStringToKey( (settings.UseNameForKeyGeneration && line.Name != null ? line.Name : string.Empty) + (settings.UseBaseTypeForKeyGeneration && line.BaseType != null ? line.BaseType : string.Empty) + (settings.UseVariantForKeyGeneration && line.Variant != null ? line.Variant : string.Empty) + (settings.UseGemLevelForKeyGeneration ? ("L" + line.GemLevel.ToString("00")) : string.Empty) + (settings.UseGemQualityForKeyGeneration ? ("Q" + line.GemQuality.ToString("00")) : string.Empty) ); }
private void GenerateItemKeys<TJsonResponse>( TJsonResponse jsonResponse, GenerateItemKeysSetting settings) where TJsonResponse : PoeNinjaDataService.ItemJsonResponse { AddToDictionary(new RegionMarker { Description = " #region " + settings.Region + " Keys" }); foreach(var line in jsonResponse.Lines) { AddToDictionary(line, settings); } AddToDictionary(new RegionMarker { Description = " #endregion " + settings.Region + " Keys" }); }
private void AddToDictionary( PoeNinjaDataService.ItemJsonResponse.Line line, GenerateItemKeysSetting settings) { // ignore any items with less then the minimum required number of links if(settings.AddLinksProperty && line.Links < settings.MinimumNumberOfLinks) { return; } // ignore any items with less then the minimum required gem level if(settings.AddGemLevelProperty && line.GemLevel < settings.MinimumGemLevel) { return; } line.Name = line.Name.Trim(); var keyNode = new KeyNode { Description = line.Name, Key = FormatStringToKey(line, settings), }; keyNode.Attributes.Add($"[Name(Name = \"{line.Name}\")]"); var attributeProperties = new List<string>(); if(line.Id != -1) { keyNode.Attributes.Add($"[PoeNinja]"); attributeProperties.Add($"PoeNinjaId = {line.Id}"); } if(settings.AddUniqueProperty) { attributeProperties.Add($"Unique = true"); } if(settings.AddMapTierProperty) { attributeProperties.Add($"MapTier = {line.MapTier}"); } if(settings.AddLinksProperty) { attributeProperties.Add($"Links = {line.Links}"); } if(settings.AddGemLevelProperty) { attributeProperties.Add($"GemLevel = {line.GemLevel}"); } if(settings.AddGemQualityProperty) { attributeProperties.Add($"Quality = {line.GemQuality}"); } var attribute = $"[{settings.AttributeTypeName}"; if(attributeProperties.Count > 0) { attribute += $"("; attribute += string.Join(", ", attributeProperties); attribute += $")"; } attribute += "]"; keyNode.Attributes.Add(attribute); AddToDictionary(keyNode); }