Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        public static ImageFormat ExtensionToSystemFormat(string extension)
        {
            string           lookup = extension.ToUpper();
            FormatDefinition fd     = _formats.FirstOrDefault(x => x.Extension == lookup);

            return(fd == null ? null : fd.SystemFormat);
        }
Ejemplo n.º 3
0
 public static bool ValidateFormat(this string value, FormatDefinition definition)
 {
     return(definition.Validate(value));
 }
Ejemplo n.º 4
0
        public static ImageFormat ImageFormatToSystemFormat(ImageFormatEnum type)
        {
            FormatDefinition fd = _formats.FirstOrDefault(x => x.Type == type);

            return(fd == null ? null : fd.SystemFormat);
        }
Ejemplo n.º 5
0
        public static string ImageFormatToDescription(ImageFormatEnum type)
        {
            FormatDefinition fd = _formats.FirstOrDefault(x => x.Type == type);

            return(fd == null ? "Unknown" : fd.Description);
        }
Ejemplo n.º 6
0
        public static ImageFormatEnum SystemFormatToEnum(ImageFormat format)
        {
            FormatDefinition fd = _formats.FirstOrDefault(x => x.SystemFormat.Equals(format));

            return(fd == null ? ImageFormatEnum.Unknown : fd.Type);
        }
Ejemplo n.º 7
0
        public static string SystemFormatToExtension(ImageFormat format)
        {
            FormatDefinition fd = _formats.FirstOrDefault(x => x.SystemFormat.Equals(format));

            return(fd == null ? ".IMAGE" : fd.Extension);
        }
Ejemplo n.º 8
0
        /// <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);
        }