Ejemplo n.º 1
0
        public static XmlEnumContractBuilder Create(XmlEnumContract contract)
        {
            if (contract == null)
            {
                throw new ArgumentNullException(nameof(contract));
            }

            return(new XmlEnumContractBuilder(contract.ValueType)
            {
                Name = contract.Name,
                Items = new XmlEnumItemCollection(contract.Items)
            });
        }
        private static long GetEnumValue(XmlEnumContract contract, string name)
        {
            name = name.Trim();

            foreach (var item in contract.Items)
            {
                if (name == item.Name)
                {
                    return(item.Value);
                }
            }

            throw new FormatException($"Enumerable name \"{name}\" of type \"{contract.ValueType}\" is invalid.");
        }