コード例 #1
0
        private IKeyedEnumerable <string, MetaMember> GetMembers(Type type)
        {
            MetaMemberCollection members = new MetaMemberCollection();

            foreach (MemberInfo member in type.GetMembers(BindingFlags.Instance |
                                                          BindingFlags.Public | BindingFlags.NonPublic))
            {
                ColumnAttribute column = (ColumnAttribute)Attribute
                                         .GetCustomAttribute(member, typeof(ColumnAttribute));
                AssociationAttribute association = (AssociationAttribute)Attribute
                                                   .GetCustomAttribute(member, typeof(AssociationAttribute));

                if (column != null)
                {
                    if (association != null)
                    {
                        throw Error.InvalidMemberAttributes(member);
                    }

                    members.Add(new AttributedMetaColumn(this, member, column));
                }
                if (association != null)
                {
                    members.Add(new AttributedMetaAssociation(this, member, association));
                }
            }
            return(members);
        }
コード例 #2
0
		public AttributedMetaAssociation (MetaType declaringType, 
			MemberInfo member, AssociationAttribute attribute)
			: base(declaringType, member)
		{
			Precondition.Require(attribute, () => Error.ArgumentNull("attribute"));
			
			_isNullable = attribute.CanBeNull;
			_isProjected = attribute.Projected;
			_isPersistent = attribute.Persistent;
			_thisKey = attribute.ThisKey ?? ((_isPersistent) ? member.Name : null);
			_otherKey = attribute.OtherKey;
			_prefix = attribute.Prefix ?? String.Concat(member.Name, ".");
		}
コード例 #3
0
        public AttributedMetaAssociation(MetaType declaringType,
                                         MemberInfo member, AssociationAttribute attribute)
            : base(declaringType, member)
        {
            Precondition.Require(attribute, () => Error.ArgumentNull("attribute"));

            _isNullable   = attribute.CanBeNull;
            _isProjected  = attribute.Projected;
            _isPersistent = attribute.Persistent;
            _thisKey      = attribute.ThisKey ?? ((_isPersistent) ? member.Name : null);
            _otherKey     = attribute.OtherKey;
            _prefix       = attribute.Prefix ?? String.Concat(member.Name, ".");
        }