private static bool TryApplyIngotConfiguration(RequestedIngotConfiguration ingotConfiguration, string[] segments) { var targetParam = segments.ElementAtOrDefault(1)?.Trim(); if (!String.IsNullOrWhiteSpace(targetParam)) { float?targetValue; if (!TryReadNumberOrNull(targetParam, out targetValue)) { return(false); } ingotConfiguration.StockpileTarget = targetValue; } var limitParam = segments.ElementAtOrDefault(2)?.Trim(); if (!String.IsNullOrWhiteSpace(limitParam)) { float?limitValue; if (!TryReadNumberOrNull(limitParam, out limitValue)) { return(false); } ingotConfiguration.StockpileLimit = limitValue; } return(true); }
private bool Enable(RequestedConfiguration configuration, string current) { var segments = current.Split(':'); var itemType = ReadIngotItemType(segments.First()); RequestedIngotConfiguration ingotConfiguration; if (!configuration.Ingots.TryGetValue(itemType, out ingotConfiguration)) { ingotConfiguration = new RequestedIngotConfiguration(); configuration.Ingots[itemType] = ingotConfiguration; } ingotConfiguration.Enable = true; if (!TryApplyIngotConfiguration(ingotConfiguration, segments)) { return(false); } return(true); }