예제 #1
0
        /// <summary>
        /// Instances the entity from its definition stored in custom attribute
        /// </summary>
        /// <param name="attribute"></param>
        /// <exception cref="System.ArgumentException">Thrown if one of the params is null</exception>
        internal static Option FromAttribute(OptionDefinitionAttribute attribute)
        {
            var opt = MapFromAttribute(attribute);

            // check type
            LOVOptionDefinitionAttribute lovAttr = attribute as LOVOptionDefinitionAttribute;

            if (lovAttr != null)
            {
                return(FromLOVAttribute((LOVOptionDefinitionAttribute)attribute));
            }

            return(opt);
        }
예제 #2
0
        /// <summary>
        /// Instances the entity from its definition stored in custom attribute
        /// </summary>
        /// <param name="attribute"></param>
        /// <exception cref="System.ArgumentException">Thrown if one of the params is null</exception>
        static Option MapFromAttribute(OptionDefinitionAttribute attribute)
        {
            if (attribute == null)
            {
                throw new ArgumentNullException(nameof(attribute));
            }

            var opt = new Option(attribute.Code, attribute.LongCode, attribute.Description);

            opt.Mandatory    = attribute.Mandatory;
            opt.DefaultValue = attribute.DefaultValue;

            return(opt);
        }