示例#1
0
        public static SerialNumber ToString(SerialNumberNumeric serialNumberNumeric)
        {
            var unvalidatedSerialNumber = Utilities.ToUnvalidatedString(serialNumberNumeric);

            var serialNumber = Utilities.Validate(unvalidatedSerialNumber);

            return(serialNumber);
        }
示例#2
0
        public static UnvalidatedSerialNumber ToUnvalidatedString(SerialNumberNumeric serialNumberNumeric)
        {
            var valueString = Utilities.DefaultSerialNumberToStringConverter(serialNumberNumeric.Value);

            var unvalidatedSerialNumber = new UnvalidatedSerialNumber(valueString);

            return(unvalidatedSerialNumber);
        }
        public static void Validate(this SerialNumberNumeric serialNumberNumeric)
        {
            var isValid = serialNumberNumeric.IsValid();

            if (!isValid.Value)
            {
                throw new ArgumentException(isValid.Message, nameof(serialNumberNumeric));
            }
        }
示例#4
0
        public static DescribedResult <bool> TryValidate(UnvalidatedSerialNumberNumeric unvalidatedSerialNumberNumeric, out SerialNumberNumeric serialNumberNumeric)
        {
            var isValid = Utilities.IsValid(unvalidatedSerialNumberNumeric);

            if (isValid.Value)
            {
                serialNumberNumeric = new SerialNumberNumeric(unvalidatedSerialNumberNumeric.Value);
            }
            else
            {
                serialNumberNumeric = SerialNumberNumeric.Invalid;
            }

            return(isValid);
        }
示例#5
0
        public static DescribedResult <bool> IsValid(SerialNumberNumeric serialNumberNumeric)
        {
            var output = Utilities.IsValidSerialNumber(serialNumberNumeric.Value);

            return(output);
        }
        public static DescribedResult <bool> TryValidate(UnvalidatedSerialNumberNumeric unvalidatedSerialNumberNumeric, out SerialNumberNumeric serialNumberNumeric)
        {
            var isValid = Utilities.TryValidate(unvalidatedSerialNumberNumeric, out serialNumberNumeric);

            return(isValid);
        }