Esempio n. 1
0
        public override bool IsValid(object value)
        {
            var array   = FromSet as object[];
            var isValid = array?.Contains(value) ?? FromSet.Equals(value);

            if (GenerateErrorMessage)
            {
                ErrorMessage = CreateErrorMessage();
            }
            return(isValid);
        }
        public bool ProcessError <TLocalised>(IOperationResponse response)
            where TLocalised : struct, IComparable, IFormattable
        {
            if (FromSet <TLocalised> .GetNames().Any(x => Format.ComparesWith(x, response.Message)))
            {
                var candidate = FromSet <TLocalised> .Get(response.Message);

                Emitter.Publish(candidate);

                return(true);
            }

            return(false);
        }
 /// <summary>
 /// As type of the operation / collection.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns>a batch operation type</returns>
 public static TypeOfCollection AsOperationType(this string source)
 {
     return(FromSet <TypeOfCollection> .Get(source));
 }
 /// <summary>
 /// As operating year.
 /// </summary>
 /// <param name="source">The source.</param>
 /// <returns>a valid batch operating year (or fails)</returns>
 public static BatchOperatingYear AsOperatingYear(this string source)
 {
     // note: this operation is safe as it will return 'not set' for any element not in the set
     return(FromSet <BatchOperatingYear> .Get($"OY_{source}"));
 }