Пример #1
0
        public static List <string> GetSimplePropertiesNames(Type type)
        {
            List <string> mappedPropertiesNames = new List <string>();
            var           mappingProperties     = type.GetProperties().Where(mp => mp.GetSetMethod() != null);


            if (type.GetInterface("IEnumerable") != null)
            {
                var childProperties = GetSimplePropertiesNames(type.GenericTypeArguments.FirstOrDefault());
                childProperties.ForEach(delegate(string propName)
                {
                    mappedPropertiesNames.Add(propName);
                });

                return(mappedPropertiesNames);
            }

            foreach (var mappedProperty in mappingProperties)
            {
                if (PropertyHelper.IsSimpleType(mappedProperty.PropertyType))
                {
                    mappedPropertiesNames.Add(BasicMappingAttribute.GetMappingColumnName(mappedProperty));
                }
                else
                {
                    var childProperties = GetSimplePropertiesNames(mappedProperty.PropertyType);
                    childProperties.ForEach(delegate(string propName)
                    {
                        mappedPropertiesNames.Add(String.Format("{0}/{1}", BasicMappingAttribute.GetMappingColumnName(mappedProperty), propName));
                    });
                }
            }
            return(mappedPropertiesNames);
        }
Пример #2
0
 protected virtual string VisitMemberAccess(MemberExpression member)
 {
     CurrentMember = member.Member;
     if (member.Expression is MemberExpression && !PropertyHelper.IsSimpleType((((MemberExpression)member.Expression).Member.DeclaringType)))
     {
         return(BasicMappingAttribute.GetMappingColumnName(((MemberExpression)member.Expression).Member) + "/" + BasicMappingAttribute.GetMappingColumnName(CurrentMember));
     }
     else
     {
         return(BasicMappingAttribute.GetMappingColumnName(CurrentMember));
     }
 }
Пример #3
0
        public static string GetViewFields <T>()
        {
            StringBuilder builder = new StringBuilder();

            builder.Append("<ViewFields>");
            var mappingProperties = typeof(T).GetProperties().Where(mp => mp.GetSetMethod() != null);

            foreach (var mappedProperty in mappingProperties)
            {
                builder.Append(String.Format("<FieldRef Name=\"{0}\" />", BasicMappingAttribute.GetMappingColumnName(mappedProperty)));
            }
            builder.Append("</ViewFields>");
            return(builder.ToString());
        }
Пример #4
0
        public static List <string> GetComplexPropertiesNames(Type type)
        {
            List <string> mappedPropertiesNames = new List <string>();
            var           mappingProperties     = type.GetProperties().Where(mp => mp.GetSetMethod() != null);

            foreach (var mappedProperty in mappingProperties)
            {
                if (!PropertyHelper.IsSimpleType(mappedProperty.PropertyType))
                {
                    mappedPropertiesNames.Add(BasicMappingAttribute.GetMappingColumnName(mappedProperty));
                }
            }
            return(mappedPropertiesNames);
        }