internal static Style ToStyle(this StylePrefix stylePrefix) { return(stylePrefix switch { StylePrefix.Fas => Style.Solid, StylePrefix.Far => Style.Regular, StylePrefix.Fab => Style.Brands, _ => throw new NotImplementedException(), });
/// <inheritdoc/> public string GetIconPath(string value) { string[] splitted = value.Split(' ', StringSplitOptions.RemoveEmptyEntries); string key; Style? style; if (splitted.Length == 1) { key = splitted[0]; style = null; } else if (splitted.Length == 2) { key = splitted[1]; StylePrefix stylePrefix = Enum.Parse <StylePrefix>(splitted[0], ignoreCase: true); style = stylePrefix.ToStyle(); } else { throw new KeyNotFoundException($"Icon \"{value}\" not found!"); } // Remove "fa-" substring key = key.Substring(_faKeyPrefix.Length); if (!Icons.TryGetValue(key, out FontAwesomeIcon icon)) { throw new KeyNotFoundException($"FontAwesome-Icon \"{key}\" not found!"); } else if (!style.HasValue) { return(icon.Svg.Values.First().Path); } else if (icon.Svg.TryGetValue(style.Value, out Svg svg)) { return(svg.Path); } else { throw new KeyNotFoundException($"FontAwesome-Style \"{style}\" not found!"); } }