public EntityDynAttribute[] GetCustomAttributes(Type attributeType, bool inherit)
        {
            if (inherit == false)
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                foreach (EntityDynAttribute attr in _attributes)
                {
                    if (attributeType.IsAssignableFrom(attr.GetType()))
                    {
                        attrs.Add(attr);
                    }
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                foreach (EntityDynAttribute attr in _attributes)
                {
                    if (attributeType.IsAssignableFrom(attr.GetType()))
                    {
                        attrs.Add(attr);
                    }
                }

                DynEntityType parentType = DynEntityTypeManager.GetEntityType(this.EntityType.BaseEntityName);
                while (parentType != null)
                {
                    if (parentType.ContainsProperty(_name))
                    {
                        foreach (EntityDynAttribute attr in parentType.GetProperty(_name).Attributes)
                        {
                            if (attributeType.IsAssignableFrom(attr.GetType()))
                            {
                                attrs.Add(attr);
                            }
                        }
                    }

                    parentType = DynEntityTypeManager.GetEntityType(parentType.BaseEntityName);
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
        public static PropertyItem P(string typeName, string propertyName)
        {
            DynEntityType            entityType = DynEntityTypeManager.GetEntityTypeMandatory(typeName);
            DynPropertyConfiguration property   = entityType.GetProperty(propertyName);

            if (property.IsInherited)
            {
                DynEntityType baseEntityType = DynEntityTypeManager.GetEntityTypeMandatory(property.InheritEntityMappingName);
                return(new PropertyItem(propertyName, baseEntityType.FullName));
            }
            else
            {
                return(new PropertyItem(propertyName, entityType.FullName));
            }
        }
        public EntityDynAttribute[] GetCustomAttributes(bool inherit)
        {
            if (inherit == false)
            {
                if (_attributes.Count > 0)
                {
                    return(_attributes.ToArray());
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                List <EntityDynAttribute> attrs = new List <EntityDynAttribute>();
                attrs.AddRange(_attributes);

                DynEntityType parentType = DynEntityTypeManager.GetEntityType(this.EntityType.BaseEntityName);
                while (parentType != null)
                {
                    attrs.AddRange(parentType.GetProperty(_name).Attributes);

                    parentType = DynEntityTypeManager.GetEntityType(parentType.BaseEntityName);
                }

                if (attrs.Count > 0)
                {
                    return(attrs.ToArray());
                }
                else
                {
                    return(null);
                }
            }
        }
Example #4
0
 /// <summary>
 /// 获取属性
 /// </summary>
 /// <param name="propertyName">属性名</param>
 /// <returns>属性</returns>
 public DynPropertyConfiguration GetEntityProperty(string propertyName)
 {
     return(_entityType.GetProperty(propertyName));
 }