示例#1
0
 public void Add(CacheMapping value)
 {
     base.Add(value.MemberInfo.Name, value);
 }
示例#2
0
        private void AddDefaultCacheMappings(MemberInfo memberInfo, TypeMapping typeMapping)
        {
            RelationshipMappingAttribute rma = (RelationshipMappingAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(RelationshipMappingAttribute),false);
            if(rma != null){

                RelationshipMapping rm = new RelationshipMapping();
                rm.Name = rma.Name;
                if(rma.ParentType != null){
                    rm.ParentType = rma.ParentType;
                    rm.ChildType = typeMapping.MappedType;
                } else {
                    rm.ParentType = typeMapping.MappedType;
                    rm.ChildType = rma.ChildType;
                }
                rm.ParentMember = rma.ParentMember;
                rm.ChildMember = rma.ChildMember;
                rm.Type = rma.Type;
                relationshipMappings.Add(rm);
            }

            CacheMappingAttribute ca = (CacheMappingAttribute)Attribute.GetCustomAttribute(memberInfo, typeof(CacheMappingAttribute), false);
            if(ca != null){
                CacheMapping cm = new CacheMapping();
                cm.Relationship = ca.Relationship == null ? rma.Name : ca.Relationship;
                cm.MemberInfo = memberInfo;
                cm.DataStore = this.dataStore;
                cm.OrderBy = ca.OrderBy;
                typeMapping.CacheMappings.Add(cm);
            } else if(rma != null){
                CacheMapping cm = new CacheMapping();
                cm.Relationship = rma.Name;
                cm.MemberInfo = memberInfo;
                cm.DataStore = this.dataStore;
                typeMapping.CacheMappings.Add(cm);
            }
        }