本文整理汇总了C#中System.Reflection.MemberInfo.GetPropertyOrFieldType方法的典型用法代码示例。如果您正苦于以下问题:C# MemberInfo.GetPropertyOrFieldType方法的具体用法?C# MemberInfo.GetPropertyOrFieldType怎么用?C# MemberInfo.GetPropertyOrFieldType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.MemberInfo
的用法示例。
在下文中一共展示了MemberInfo.GetPropertyOrFieldType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsOneToMany
private bool IsOneToMany(MemberInfo member, bool declared)
{
if (declared) return true;
if (member.GetPropertyOrFieldType().IsGenericCollection() == false) return false;
var collectionElementType = member.GetPropertyOrFieldType().GetGenericArguments().First();
var isOneToMany = ManyToMany.IsManyToMany(member) == false && Mapper.ModelInspector.IsEntity(collectionElementType);
return isOneToMany;
}
示例2: Component
public void Component(MemberInfo property, Action<IComponentElementMapper> mapping)
{
System.Type nestedComponentType = property.GetPropertyOrFieldType();
var hbm = new HbmNestedCompositeElement { name = property.Name, @class = nestedComponentType.GetShortClassName(_mapDoc) };
mapping(new ComponentNestedElementMapper(nestedComponentType, _mapDoc, hbm, property));
AddProperty(hbm);
}
示例3: OneToOne
public virtual void OneToOne(MemberInfo property, Action<IOneToOneMapper> mapping)
{
var hbm = new HbmOneToOne {name = property.Name};
var type = typeof(OneToOneMapper<>).MakeGenericType(property.GetPropertyOrFieldType());
var mapper = (IOneToOneMapper)Activator.CreateInstance(type, property, hbm);
mapping(mapper);
AddProperty(hbm);
}
示例4: should_get_value
public void should_get_value(CachedMember cachedMember, MemberInfo memberInfo)
{
var @object = new Members();
@object.SetPropertyOrFieldValue(memberInfo.Name,
memberInfo.GetPropertyOrFieldType() == typeof(string) ?
"hai" : (object)(Optional<string>)"hai");
cachedMember.GetValue(@object).As<string>().ShouldEqual("hai");
}
示例5: IdBag
public virtual void IdBag(MemberInfo property, Action<IIdBagPropertiesMapper> collectionMapping, Action<ICollectionElementRelation> mapping)
{
var hbm = new HbmIdbag { name = property.Name };
System.Type propertyType = property.GetPropertyOrFieldType();
System.Type collectionElementType = propertyType.DetermineCollectionElementType();
collectionMapping(new IdBagMapper(container, collectionElementType, hbm));
mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel));
AddProperty(hbm);
}
示例6: Set
public virtual void Set(MemberInfo property, Action<ISetPropertiesMapper> collectionMapping, Action<ICollectionElementRelation> mapping)
{
var hbm = new HbmSet { name = property.Name };
var propertyType = property.GetPropertyOrFieldType();
var collectionElementType = propertyType.DetermineCollectionElementType();
collectionMapping(new SetMapper(container, collectionElementType, hbm));
mapping(new CollectionElementRelation(collectionElementType, MapDoc, rel => hbm.Item = rel));
AddProperty(hbm);
}
示例7: Component
public virtual void Component(MemberInfo property, Action<IComponentMapper> mapping)
{
if (!IsMemberSupportedByMappedContainer(property))
{
throw new ArgumentOutOfRangeException("property", "Can't add a property of another graph");
}
var hbm = new HbmComponent { name = property.Name };
mapping(new ComponentMapper(hbm, property.GetPropertyOrFieldType(), property, MapDoc));
AddProperty(hbm);
}
示例8: Property
public void Property(MemberInfo property, Action<IPropertyMapper> mapping)
{
var hbmProperty = new HbmProperty
{
name = property.Name,
type1 = property.GetPropertyOrFieldType().GetNhTypeName()
};
mapping(new PropertyMapper(property, hbmProperty, new NoMemberPropertyMapper()));
AddProperty(hbmProperty);
}
示例9: Match
public override bool Match(MemberInfo subject)
{
bool isBidirectionalUnaryAssociation = base.Match(subject);
if (isBidirectionalUnaryAssociation)
{
Type from = subject.DeclaringType;
Type to = subject.GetPropertyOrFieldType();
return DomainInspector.IsOneToOne(from, to) && DomainInspector.IsMasterOneToOne(from, to)
&& DomainInspector.IsOneToOne(to, from);
}
return false;
}
开发者ID:alvarezdaniel,项目名称:conformando-nhibernate,代码行数:12,代码来源:BidirectionalPrimaryKeyAssociationMasterOneToOnePattern.cs
示例10: Map
public virtual void Map(MemberInfo property, Action<IMapPropertiesMapper> collectionMapping,
Action<IMapKeyRelation> keyMapping, Action<ICollectionElementRelation> mapping)
{
var hbm = new HbmMap {name = property.Name};
System.Type propertyType = property.GetPropertyOrFieldType();
System.Type dictionaryKeyType = propertyType.DetermineDictionaryKeyType();
System.Type dictionaryValueType = propertyType.DetermineDictionaryValueType();
collectionMapping(new MapMapper(container, dictionaryKeyType, dictionaryValueType, hbm, mapDoc));
keyMapping(new MapKeyRelation(dictionaryKeyType, hbm, mapDoc));
mapping(new CollectionElementRelation(dictionaryValueType, MapDoc, rel => hbm.Item1 = rel));
AddProperty(hbm);
}
示例11: MemberMatch
protected override bool MemberMatch(MemberInfo subject)
{
Type memberType = subject.GetPropertyOrFieldType();
if (typeof(IDictionary).IsAssignableFrom(memberType))
{
return true;
}
if (memberType.IsGenericType)
{
return memberType.GetGenericIntercafesTypeDefinitions().Contains(typeof(IDictionary<,>));
}
return false;
}
示例12: IsSetFieldType
private static bool IsSetFieldType(MemberInfo mi, bool declared)
{
var propertyTypeIsSet = mi.GetPropertyOrFieldType()
.GetGenericIntercafesTypeDefinitions()
.Contains(typeof (ISet<>));
if (propertyTypeIsSet) return true;
var backFieldInfo = PropertyToField.GetBackFieldInfo((PropertyInfo) mi);
return backFieldInfo != null
&& backFieldInfo
.FieldType.GetGenericIntercafesTypeDefinitions().Contains(typeof (ISet<>));
}
示例13: MatchOneToMany
private bool MatchOneToMany(MemberInfo memberInfo)
{
var modelInspector = (IModelInspector) this;
System.Type from = memberInfo.ReflectedType;
System.Type to = memberInfo.GetPropertyOrFieldType().DetermineCollectionElementOrDictionaryValueType();
if(to == null)
{
// no generic collection or simple property
return false;
}
bool areEntities = modelInspector.IsEntity(from) && modelInspector.IsEntity(to);
bool isFromComponentToEntity = modelInspector.IsComponent(from) && modelInspector.IsEntity(to);
return !declaredModel.IsManyToMany(memberInfo) && (areEntities || isFromComponentToEntity);
}
示例14: IdMapper
public IdMapper(MemberInfo member, HbmId hbmId)
{
this.hbmId = hbmId;
if (member != null)
{
var idType = member.GetPropertyOrFieldType();
hbmId.name = member.Name;
hbmId.type1 = idType.GetNhTypeName();
accessorMapper = new AccessorPropertyMapper(member.DeclaringType, member.Name, x => hbmId.access = x);
}
else
{
accessorMapper = new NoMemberPropertyMapper();
}
}
示例15: MemberMatch
protected override bool MemberMatch(MemberInfo subject)
{
Type memberType = subject.GetPropertyOrFieldType();
if (IsNotSupportedAsList(memberType))
{
return false;
}
if (typeof (IList).IsAssignableFrom(memberType))
{
return true;
}
if (memberType.IsGenericType)
{
var isList = memberType.GetGenericIntercafesTypeDefinitions().Contains(typeof(IList<>));
// a bidirectional one-to-many should use Bag or Set
return isList && !(new BidirectionalOneToManyPattern(domainInspector).Match(new Relation(subject.DeclaringType, memberType.DetermineCollectionElementType())));
}
return false;
}