Beispiel #1
0
        /// <summary>Adds string property to descriptor with previously chained name.</summary>
        /// <param name="splitType">How to split string.</param>
        /// <param name="separator">(Optional) Separator to use.</param>
        /// <param name="exclusions">(Optional) file describing strings to exclude.</param>
        /// <returns>descriptor with added property.</returns>
        public Descriptor AsString(StringSplitType splitType, string separator = " ", string exclusions = null)
        {
            StringProperty p = new StringProperty
            {
                Name      = _name,
                SplitType = splitType,
                Separator = separator
            };

            p.ImportExclusions(exclusions);
            p.AsEnum = _label;
            AddProperty(p);
            return(_descriptor);
        }
Beispiel #2
0
        /// <summary>Generates a property.</summary>
        /// <exception cref="InvalidOperationException">Thrown when the requested operation is invalid.</exception>
        /// <param name="property">The property.</param>
        /// <returns>The property.</returns>
        public override Property GenerateProperty(PropertyInfo property)
        {
            if (property.PropertyType != typeof(string))
            {
                throw new InvalidOperationException("Must use a string property.");
            }

            var sp = new StringProperty
            {
                Name      = property.Name,
                SplitType = SplitType,
                Separator = Separator,
                AsEnum    = AsEnum,
                Discrete  = true
            };

            if (!string.IsNullOrWhiteSpace(ExclusionFile))
            {
                sp.ImportExclusions(ExclusionFile);
            }


            return(sp);
        }