public static float GetFloatAttribute( this ITextAttributes attributes, TextAttribute type, float defaultValue) { var value = attributes.GetAttribute(type); if (value != null) { if (float.TryParse(value, out var floatValue)) { return(floatValue); } } return(defaultValue); }
public static int GetIntAttribute( this ITextAttributes attributes, TextAttribute type, int defaultValue) { var value = attributes.GetAttribute(type); if (value != null) { if (int.TryParse(value, out var intValue)) { return(intValue); } } return(defaultValue); }
public static T GetEnumAttribute <T>( this ITextAttributes attributes, TextAttribute type, T defaultValue) where T : struct { var value = attributes.GetAttribute(type); if (value != null) { if (Enum.TryParse(value, out T enumValue)) { return(enumValue); } } return(defaultValue); }
public static bool GetBoolAttribute( this ITextAttributes attributes, TextAttribute type, bool defaultValue = false) { var value = attributes.GetAttribute(type); if (value != null) { if (bool.TryParse(value, out var boolValue)) { return(boolValue); } } return(defaultValue); }
public static string GetFontName(this ITextAttributes attributes) { return(attributes.GetAttribute(TextAttribute.FontName)); }
public static string GetBackgroundColor(this ITextAttributes attributes) => attributes.GetAttribute(TextAttribute.Background);
public static string GetForegroundColor(this ITextAttributes attributes) => attributes.GetAttribute(TextAttribute.Color);