public static bool TryParse(string value, out FontAwesomeIconKey key) { var parts = value.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length == 1) { key = new FontAwesomeIconKey { Value = GetValue(parts[0]), }; return(true); } if (parts.Length == 2) { key = new FontAwesomeIconKey { Style = GetStyle(parts[0]), Value = GetValue(parts[1]), }; return(true); } key = null; return(false); }
/// <inheritdoc/> public string GetIconPath(string value) { if (!FontAwesomeIconKey.TryParse(value, out FontAwesomeIconKey key)) { throw new KeyNotFoundException($"FontAwesome Icon \"{value}\" not found!"); } else if (!Icons.TryGetValue(key.Value, out FontAwesomeIcon icon)) { throw new KeyNotFoundException($"FontAwesome Icon \"{key.Value}\" not found!"); } else if (!key.Style.HasValue) { return(icon.Svg.Values.First().Path); } else if (icon.Svg.TryGetValue(key.Style.Value, out Svg svg)) { return(svg.Path); } throw new KeyNotFoundException($"FontAwesome Style \"{key.Style}\" not found!"); }