示例#1
0
        /// <summary>
        /// Handles the value types.
        /// </summary>
        /// <param name="container">The container.</param>
        /// <param name="property">The property.</param>
        /// <param name="tag">The tag.</param>
        private bool HandleValueTypes(IElementContainer container, PropertyInfo property, string tag)
        {
            if (property.PropertyType == typeof(bool))
            {
                container.Add(new BooleanElement(tag, property));
            }
            else if (property.PropertyType == typeof(byte))
            {
                container.Add(new ByteElement(tag, property));
            }
            else if (property.PropertyType == typeof(char))
            {
                container.Add(new CharElement(tag, property));
            }
            else if (property.PropertyType == typeof(double))
            {
                container.Add(new DoubleElement(tag, property));
            }
            else if (property.PropertyType == typeof(float))
            {
                container.Add(new FloatElement(tag, property));
            }
            else if (property.PropertyType == typeof(Guid))
            {
                container.Add(new GuidElement(tag, "D", property));
            }
            else if (property.PropertyType == typeof(int))
            {
                container.Add(new IntegerElement(tag, property));
            }
            else if (property.PropertyType == typeof(long))
            {
                container.Add(new LongElement(tag, property));
            }
            else if (property.PropertyType == typeof(short))
            {
                container.Add(new ShortElement(tag, property));
            }
            else if (property.PropertyType == typeof(string))
            {
                container.Add(new StringElement(tag, property));
            }
            else if (property.PropertyType == typeof(Type))
            {
                container.Add(new TypeElement(tag, property));
            }
            else
            {
                return(false);
            }

            return(true);
        }