本文整理汇总了C#中IPropertyMap.GetDataOrItemType方法的典型用法代码示例。如果您正苦于以下问题:C# IPropertyMap.GetDataOrItemType方法的具体用法?C# IPropertyMap.GetDataOrItemType怎么用?C# IPropertyMap.GetDataOrItemType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IPropertyMap
的用法示例。
在下文中一共展示了IPropertyMap.GetDataOrItemType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MustGetTypeFromPropertyMap
public virtual Type MustGetTypeFromPropertyMap(IPropertyMap propertyMap)
{
Type type = GetTypeFromPropertyMap(propertyMap);
if (type == null)
throw new MappingException("Could not find the type " + propertyMap.GetDataOrItemType() + " for the property " + propertyMap.ClassMap.Name + "." + propertyMap.Name + " (found in the map file) in any loaded Assembly!");
return type;
}
示例2: VerifyReference
private void VerifyReference(IPropertyMap propertyMap)
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
if (propertyMap.ReferenceType == ReferenceType.OneToOne || propertyMap.ReferenceType == ReferenceType.OneToMany)
{
if (propertyMap.IsCollection)
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyColumnIsForeignKey(propertyMap);
}
else if (propertyMap.ReferenceType == ReferenceType.ManyToOne)
{
if (!(propertyMap.IsCollection))
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyIDColumnIsForeignKey(propertyMap);
}
else if (propertyMap.ReferenceType == ReferenceType.ManyToMany)
{
if (!(propertyMap.IsCollection))
{
HandleVerifyException(propertyMap, "Reference type must not be set to " + propertyMap.ReferenceType.ToString() + " for a non-collection property! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "ReferenceType"); // do not localize
}
VerifyColumnIsForeignKey(propertyMap);
VerifyIDColumnIsForeignKey(propertyMap);
}
IClassMap referencedClassMap = propertyMap.GetReferencedClassMap() ;
if (referencedClassMap == null)
{
HandleVerifyException(propertyMap, "Reference type class not found! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Referenced class: '" + propertyMap.DataType + "')", "DataType"); // do not localize
}
else
{
if (referencedClassMap.ClassType == ClassType.Interface)
{
HandleVerifyException(propertyMap, "Persistent reference properties can not use interfaces as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
}
else if (referencedClassMap.ClassType == ClassType.Struct)
{
HandleVerifyException(propertyMap, "Persistent reference properties can not use structs as types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "DataType"); // do not localize
}
else if (referencedClassMap.ClassType == ClassType.Enum)
{
HandleVerifyException(propertyMap, "Reference type should be set to None for properties with enumeration types! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Type: '" + propertyMap.GetDataOrItemType() + "')", "ReferenceType"); // do not localize
}
}
}
else
{
if (!(propertyMap.ReferenceType == ReferenceType.None))
{
HandleVerifyException(propertyMap, "Reference type must be set None for non-reference properties! (Class: '" + propertyMap.ClassMap.Name + "', Property: '" + propertyMap.Name + "', Reference type: '" + propertyMap.ReferenceType + "')", "DataType"); // do not localize
}
}
}
示例3: GetTypeFromPropertyMap
public virtual Type GetTypeFromPropertyMap(IPropertyMap propertyMap)
{
Type type = null;
string dataType = propertyMap.GetDataOrItemType() ;
IClassMap classMap = propertyMap.ClassMap.DomainMap.GetClassMap(dataType);
if (classMap != null)
{
type = Type.GetType(classMap.GetFullName() + ", " + classMap.GetAssemblyName());
if (type == null)
{
foreach (Assembly asm in m_LoadedAssemblies.Values)
{
type = asm.GetType(classMap.GetFullName());
if (type != null)
{
break;
}
}
}
}
else
{
type = Type.GetType(dataType);
if (type == null)
{
IDomainMap domainMap = propertyMap.ClassMap.DomainMap;
string fullName = dataType;
if (domainMap.RootNamespace.Length > 0)
fullName = domainMap.RootNamespace + "." + fullName;
type = Type.GetType(fullName + ", " + domainMap.GetAssemblyName());
}
}
return type;
}