private void AddPropToCard <T>(BasicCard card, string?propRef, string propName, Dictionary <string, T> valueDic, Action <BasicCard, T> valueSetter) where T : class { if (!string.IsNullOrWhiteSpace(propRef)) { if (valueDic.TryGetValue(propRef, out T? value)) { valueSetter(card, value); } else { LogUnrecognizedPropWarning(card, propName, propRef); } } }
private void AddPropListToCard <T>(BasicCard card, IReadOnlyList <string>?propRefs, string propName, Dictionary <string, T> valueDic, Action <BasicCard, IReadOnlyList <T> > valuesSetter) where T : class { if (propRefs != null) { var values = new List <T>(); foreach (string propRef in propRefs.Where(r => !string.IsNullOrWhiteSpace(r))) { if (valueDic.TryGetValue(propRef, out T? value)) { values.Add(value); } else { LogUnrecognizedPropWarning(card, propName, propRef); } } valuesSetter(card, values); } }
private void LogUnrecognizedPropWarning(BasicCard card, string propName, string propRef) { Logger.LogWarning($"{card} references an unrecognized {propName} '{propRef}'. Ignoring this {propName}."); }