protected override bool TryGetValue(XField xField, out TProperty value) { XAttribute attribute = xField.Attribute(AttributeName); if (attribute == null || attribute.Value == "") { value = default(TProperty); return(false); } value = (TProperty)Converter.ConvertFromString(attribute.Value); return(true); }
private static bool GetBackgroundColor(XField xField, out Color value) { XAttribute attribute = xField.Attribute(ColumnNames.BACKGROUND_COLOR); if (attribute == null || attribute.Value == "") { value = Color.Empty; return(false); } value = Color.FromArgb((int)attribute); return(true); }
private static bool TryGetOptions(XField xField, out List <string> value) { string options = (string)xField.Attribute(ColumnNames.LIST); int index = options.IndexOf(OptionsSeparator); if (index != -1) { options = options.Substring(0, index); } value = options.Split(Constants.LIST_SEPARATOR).ToList(); return(true); }
private static bool TryGetFont(XField xField, string propertyName, out Font value) { ICollection <string> keys = new string[] { "Family", "Size", "Style" }; IDictionary <string, XAttribute> attributes = keys.ToDictionary( key => key, key => xField.Attribute($"{propertyName}{key}")); if (attributes.Values.Any(attribute => attribute == null || attribute.Value == "")) { value = null; return(false); } FontFamily family = new FontFamily((string)attributes["Family"]); float size = (float)attributes["Size"]; FontStyle style = (FontStyle)Enum.Parse(typeof(FontStyle), (string)attributes["Style"]); value = new Font(family, size, style); return(true); }