本文整理汇总了C#中MemberAccessor.IsDefined方法的典型用法代码示例。如果您正苦于以下问题:C# MemberAccessor.IsDefined方法的具体用法?C# MemberAccessor.IsDefined怎么用?C# MemberAccessor.IsDefined使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MemberAccessor
的用法示例。
在下文中一共展示了MemberAccessor.IsDefined方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAssociation
public override Association GetAssociation(TypeExtension typeExtension, MemberAccessor member)
{
if (member.Type.IsClass && !member.Type.FullName.StartsWith("System"))
{
bool canBeNull = !member.IsDefined<RequiredAttribute>();
Type otherType = member.Type;
if(otherType.IsGenericType)
otherType = otherType.GetGenericArguments()[0];
string[] otherKeys = null;
string[] thisKeys = null;
if (member.IsDefined<System.ComponentModel.DataAnnotations.AssociationAttribute>())
{
var asAttr = member.GetAttribute<System.ComponentModel.DataAnnotations.AssociationAttribute>();
thisKeys = asAttr.ThisKeyMembers.ToArray();
otherKeys = asAttr.OtherKeyMembers.ToArray();
}
else if (member.IsDefined<ForeignKeyAttribute>())
{
var fkAttr = member.GetAttribute<ForeignKeyAttribute>();
otherKeys = GetTypeKeyNames(otherType);
thisKeys = fkAttr.Name.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}
else
{
otherKeys = GetTypeKeyNames(otherType);
thisKeys = otherKeys;
}
if (thisKeys != null && otherKeys != null && thisKeys.Length == otherKeys.Length && thisKeys.Length > 0)
{
return new Association(
member,
thisKeys,
otherKeys,
string.Format("FK_{0}_{1}", member.TypeAccessor.Type, otherType),
canBeNull);
}
}
return base.GetAssociation(typeExtension, member);
}
示例2: GetNonUpdatableFlag
public override bool GetNonUpdatableFlag(Type type, TypeExtension typeExt, MemberAccessor member, out bool isSet)
{
if (member.IsDefined<NonUpdatableAttribute>())
{
isSet = true;
return true;
}
return base.GetNonUpdatableFlag(type, typeExt, member, out isSet);
}
示例3: GetMapIgnore
public override bool GetMapIgnore(TypeExtension typeExtension, MemberAccessor member, out bool isSet)
{
if (member.IsDefined<NotMappedAttribute>() || member.IsDefined<ScaffoldColumnAttribute>() ||
member.IsDefined<System.ComponentModel.DataAnnotations.AssociationAttribute>())
{
isSet = true;
return true;
}
if (member.IsDefined<ColumnAttribute>())
{
isSet = true;
return false;
}
return base.GetMapIgnore(typeExtension, member, out isSet);
}