Beispiel #1
0
        public Property(MemberInfo member, HttpApplication httpApp)
        {
            this.IsIdentfier = member.ContainsAttributeInterface <IIdentifyResource>();
            this.IsTitle     = member.ContainsAttributeInterface <ITitleResource>();
            this.Name        = member.GetCustomAttribute <JsonPropertyAttribute, string>(
                (attr) => attr.PropertyName.HasBlackSpace() ? attr.PropertyName : member.Name,
                () => member.Name);
            this.Description = member.GetCustomAttribute <System.ComponentModel.DescriptionAttribute, string>(
                (attr) => attr.Description,
                () => string.Empty);
            this.Options = new KeyValuePair <string, string>[] { };
            var type = member.GetPropertyOrFieldType();

            this.Type = Parameter.GetTypeName(type, httpApp);
        }
        public Property GetProperty(MemberInfo member, HttpApplication httpApp)
        {
            string GetName()
            {
                if (this.PropertyName.HasBlackSpace())
                {
                    return(this.PropertyName);
                }
                return(member.GetCustomAttribute <JsonPropertyAttribute, string>(
                           (attr) => attr.PropertyName.HasBlackSpace() ? attr.PropertyName : member.Name,
                           () => member.Name));
            }

            string GetDescription()
            {
                return(member.GetCustomAttribute <System.ComponentModel.DescriptionAttribute, string>(
                           (attr) => attr.Description,
                           () => string.Empty));
            }

            string GetType()
            {
                var type = member.GetPropertyOrFieldType();

                return(Parameter.GetTypeName(type, httpApp));
            }

            var name        = GetName();
            var description = GetDescription();
            var options     = new KeyValuePair <string, string>[] { };

            return(new Property()
            {
                IsIdentfier = member.ContainsAttributeInterface <IIdentifyResource>(),
                IsTitle = member.ContainsAttributeInterface <ITitleResource>(),
                Name = name,
                Description = description,
                Options = options,
                Type = GetType(),
            });
        }