public static ImageFormatEnum ExtensionToEnum(string extension) { string lookup = extension.ToUpper(); FormatDefinition fd = _formats.FirstOrDefault(x => x.Extension == lookup); return(fd == null ? ImageFormatEnum.Unknown : fd.Type); }
public static ImageFormat ExtensionToSystemFormat(string extension) { string lookup = extension.ToUpper(); FormatDefinition fd = _formats.FirstOrDefault(x => x.Extension == lookup); return(fd == null ? null : fd.SystemFormat); }
public static bool ValidateFormat(this string value, FormatDefinition definition) { return(definition.Validate(value)); }
public static ImageFormat ImageFormatToSystemFormat(ImageFormatEnum type) { FormatDefinition fd = _formats.FirstOrDefault(x => x.Type == type); return(fd == null ? null : fd.SystemFormat); }
public static string ImageFormatToDescription(ImageFormatEnum type) { FormatDefinition fd = _formats.FirstOrDefault(x => x.Type == type); return(fd == null ? "Unknown" : fd.Description); }
public static ImageFormatEnum SystemFormatToEnum(ImageFormat format) { FormatDefinition fd = _formats.FirstOrDefault(x => x.SystemFormat.Equals(format)); return(fd == null ? ImageFormatEnum.Unknown : fd.Type); }
public static string SystemFormatToExtension(ImageFormat format) { FormatDefinition fd = _formats.FirstOrDefault(x => x.SystemFormat.Equals(format)); return(fd == null ? ".IMAGE" : fd.Extension); }
/// <summary> /// Class String Property Validation Rule Method /// </summary> /// <param name="property">String property being validated</param> /// <param name="rule">String format rule definition (Regex) being used</param> /// <param name="message">Error message</param> /// <returns>Validation context</returns> public ValidationResult <TModel> Rule(Expression <Func <TModel, string> > property, FormatDefinition rule, string message = null) { if (this._breakIfIsInvalid && !this.Success) { return(this); } this._breakIfIsInvalid = false; if (!GetMember(property, out var member)) { return(this); } var index = 0; foreach (var value in this.Values) { var propertyValue = value.GetPropertyValue <string>(member.Name); this.AddItem(rule.Validate(propertyValue), message, member.Name, member.Name, index); index++; } return(this); }