本文整理汇总了C#中IClassMap.GetAllPropertyMaps方法的典型用法代码示例。如果您正苦于以下问题:C# IClassMap.GetAllPropertyMaps方法的具体用法?C# IClassMap.GetAllPropertyMaps怎么用?C# IClassMap.GetAllPropertyMaps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IClassMap
的用法示例。
在下文中一共展示了IClassMap.GetAllPropertyMaps方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetOptionalPropertyMaps
private static IList GetOptionalPropertyMaps(IClassMap classMap)
{
IList optionalPropertyMaps = new ArrayList();
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (!propertyMap.IsIdentity)
{
if (!propertyMap.IsCollection)
if (propertyMap.GetIsNullable())
optionalPropertyMaps.Add(propertyMap);
}
}
return optionalPropertyMaps;
}
示例2: DeserializeObject
protected virtual void DeserializeObject(object obj, IClassMap classMap, XmlNode xmlObject, bool idOnly)
{
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (idOnly == false || propertyMap.IsIdentity )
{
if (propertyMap.ReferenceType == ReferenceType.None)
{
if (propertyMap.IsCollection)
{
;
}
else
{
DeserializeInlineProperty(obj, classMap, propertyMap, xmlObject);
}
}
else
{
//if (propertyMap.DocPropertyMapMode == DocPropertyMapMode.Default || propertyMap.DocPropertyMapMode == DocPropertyMapMode.Inline)
if (propertyMap.DocPropertyMapMode == DocPropertyMapMode.Inline)
{
if (propertyMap.IsCollection)
{
//DeserializeInlineReferenceList(obj, classMap, propertyMap, xmlObject);
}
else
{
DeserializeInlineObject(obj, classMap, propertyMap, xmlObject);
}
}
else
{
if (propertyMap.IsCollection)
{
DeserializeInlineReferenceList(obj, classMap, propertyMap, xmlObject);
}
else
{
DeserializeInlineReference(obj, classMap, propertyMap, xmlObject);
}
}
}
}
}
}
示例3: GetRequiredPropertyMaps
private static IList GetRequiredPropertyMaps(IClassMap classMap)
{
IList requiredPropertyMaps = new ArrayList();
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (propertyMap.IsIdentity)
{
if (!propertyMap.GetIsAssignedBySource())
requiredPropertyMaps.Add(propertyMap);
}
else
{
if (!propertyMap.IsCollection)
if (!propertyMap.GetIsNullable())
requiredPropertyMaps.Add(propertyMap);
}
}
return requiredPropertyMaps;
}
示例4: SerializeObject
protected virtual void SerializeObject(XmlNode xmlObject, object obj, IClassMap classMap, bool creating, bool specifyClass)
{
if (specifyClass)
SetAttributeValue(xmlObject, "class", classMap.GetFullName() );
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (propertyMap.ReferenceType == ReferenceType.None)
{
if (propertyMap.IsCollection)
{
;
}
else
{
SerializeInlineProperty(xmlObject, obj, classMap, propertyMap, creating);
}
}
else
{
//if (propertyMap.DocPropertyMapMode == DocPropertyMapMode.Default || propertyMap.DocPropertyMapMode == DocPropertyMapMode.Inline)
if (propertyMap.DocPropertyMapMode == DocPropertyMapMode.Inline)
{
if (propertyMap.IsCollection)
{
SerializeInlineObjectList(xmlObject, obj, classMap, propertyMap, creating);
}
else
{
SerializeInlineObject(xmlObject, obj, classMap, propertyMap, creating);
}
}
else
{
if (propertyMap.IsCollection)
{
SerializeInlineReferenceList(xmlObject, obj, classMap, propertyMap, creating);
}
else
{
SerializeInlineReference(xmlObject, obj, classMap, propertyMap, creating);
}
}
}
}
}
示例5: SetupTableColumns
private void SetupTableColumns(object obj, DataTable table, IClassMap classMap, IContext context, string prefix)
{
object refObj;
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (context.GetPropertyStatus(obj, propertyMap.Name) == PropertyStatus.NotLoaded)
{
}
else
{
if (!(propertyMap.IsCollection))
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
}
else
{
if (!(table.Columns.Contains(prefix + propertyMap.Name)))
{
table.Columns.Add(prefix + propertyMap.Name, obj.GetType().GetProperty(propertyMap.Name).PropertyType );
}
}
}
}
}
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (context.GetPropertyStatus(obj, propertyMap.Name) == PropertyStatus.NotLoaded)
{
}
else
{
if (!(propertyMap.IsCollection))
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
refObj = context.ObjectManager.GetPropertyValue(obj, propertyMap.Name);
if (refObj == null)
{
}
else
{
SetupTableColumns(refObj,
table, propertyMap.GetReferencedClassMap(),
context,
prefix + propertyMap.Name + ".");
}
}
else
{
}
}
}
}
}
示例6: AddObjectToTable
private void AddObjectToTable(object obj, DataTable table, IClassMap classMap, IContext context, string prefix, DataRow dr)
{
object refObj;
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (!(propertyMap.IsCollection))
{
if (context.GetPropertyStatus(obj, propertyMap.Name) != PropertyStatus.NotLoaded)
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
}
else
{
if (table.Columns.Contains(prefix + propertyMap.Name))
{
if (obj.GetType().GetProperty(propertyMap.Name).GetValue(obj, null) == null)
{
dr[prefix + propertyMap.Name] = System.DBNull.Value;
}
else
{
dr[prefix + propertyMap.Name] = obj.GetType().GetProperty(propertyMap.Name).GetValue(obj, null);
}
}
}
}
}
}
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
if (!(propertyMap.IsCollection))
{
if (context.GetPropertyStatus(obj, propertyMap.Name) != PropertyStatus.NotLoaded)
{
if (propertyMap.ReferenceType != ReferenceType.None)
{
refObj = obj.GetType().GetProperty(propertyMap.Name).GetValue(obj, null);
if (refObj == null)
{
if (table.Columns.Contains(prefix + propertyMap.Name))
{
dr[prefix + propertyMap.Name] = System.DBNull.Value;
}
}
else
{
AddObjectToTable(refObj,
table,
context.DomainMap.MustGetClassMap(refObj.GetType()),
context,
prefix + propertyMap.Name + ".",
dr);
}
}
else
{
}
}
}
}
if (prefix == "")
{
table.Rows.Add(dr);
}
}
示例7: GenerateRepositoryUpdateObjectMethod
public static void GenerateRepositoryUpdateObjectMethod(IClassMap classMap, CodeTypeDeclaration classDecl)
{
IList propertyMaps = classMap.GetAllPropertyMaps();
IList idPropertyMaps = classMap.GetIdentityPropertyMaps();
CodeMemberMethod methodMember = new CodeMemberMethod() ;
methodMember.Name = GetRepositoryUpdateObjectMethodName(classMap);
CodeTypeReference typeReference = new CodeTypeReference(classMap.GetName());
methodMember.ReturnType = typeReference;
methodMember.Attributes = MemberAttributes.Public;
foreach(IPropertyMap propertyMap in propertyMaps)
{
if (!propertyMap.IsCollection)
{
CodeParameterDeclarationExpression parameter = new CodeParameterDeclarationExpression(new CodeTypeReference(propertyMap.DataType), MakeCamelCase(propertyMap.Name));
methodMember.Parameters.Add(parameter);
}
}
CodeThisReferenceExpression thisExp = new CodeThisReferenceExpression();
CodeFieldReferenceExpression contextVar = new CodeFieldReferenceExpression(thisExp, "context");
CodeExpression[] createParams = new CodeExpression[idPropertyMaps.Count];
int i = 0;
foreach(IPropertyMap idPropertyMap in idPropertyMaps)
{
CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(idPropertyMap.Name));
createParams[i] = argExp;
i++;
}
CodeMethodInvokeExpression newObjectInit = new CodeMethodInvokeExpression(thisExp, GetRepositoryGetByIdentityMethodName(classMap), createParams ) ;
CodeVariableDeclarationStatement newObjectVarDecl = new CodeVariableDeclarationStatement(classMap.GetName(), MakeCamelCase(classMap.GetName()), newObjectInit) ;
CodeVariableReferenceExpression newObjectVar = new CodeVariableReferenceExpression(MakeCamelCase(classMap.GetName()));
methodMember.Statements.Add(newObjectVarDecl);
foreach(IPropertyMap propertyMap in propertyMaps)
{
if (!propertyMap.IsIdentity)
{
if (!propertyMap.IsCollection)
{
CodeArgumentReferenceExpression argExp = new CodeArgumentReferenceExpression(MakeCamelCase(propertyMap.Name));
CodeVariableReferenceExpression propExp = new CodeVariableReferenceExpression(MakeCamelCase(classMap.Name) + "." + propertyMap.Name);
CodeAssignStatement assignStatement = new CodeAssignStatement(propExp, argExp);
methodMember.Statements.Add(assignStatement);
}
}
}
CodeMethodInvokeExpression commitCtx = new CodeMethodInvokeExpression(contextVar, "Commit", new CodeExpression[] {} ) ;
methodMember.Statements.Add(commitCtx);
CodeMethodReturnStatement returnStmt = new CodeMethodReturnStatement(newObjectVar) ;
methodMember.Statements.Add(returnStmt);
classDecl.Members.Add(methodMember);
}
示例8: VerifyClassMap
public virtual void VerifyClassMap(IClassMap classMap)
{
bool failedSorting = false;
IClassMap superClassMap = null;
if (classMap.Name.Length < 1)
{
HandleVerifyException(classMap, "Class name must not be empty!", "Name"); // do not localize
}
if (classMap.ClassType == ClassType.Class || classMap.ClassType == ClassType.Default)
{
superClassMap = classMap.GetInheritedClassMap();
if (superClassMap != null)
{
if (!(classMap.IsLegalAsSuperClass(superClassMap)))
{
HandleVerifyException(classMap, "Inherited class '" + superClassMap.Name + "' is illegal as superclass for this class! Creates cyclic inheritance graph, which is a very serious error, potentially leading to infinite loops! No more verification of this class or its properties will be made until this error is corrected! (" + GetClassType(classMap) + ": '" + classMap.Name + "')", "InheritsClass"); // do not localize
return;
}
}
bool checkMappings = this.checkOrmMappings;
if (classMap.IsAbstract)
{
if (classMap.InheritanceType == InheritanceType.ConcreteTableInheritance)
{
checkMappings = false;
}
}
if (checkMappings)
{
if (classMap.SourceClass.Length > 0)
{
if (classMap.GetSourceClassMap() == null)
{
HandleVerifyException(classMap, "Source class not found! (Class: '" + classMap.Name + "', Source class: '" + classMap.SourceClass + "')", "SourceClass"); // do not localize
}
}
else
{
if (classMap.Table.Length < 1)
{
HandleVerifyException(classMap, "Table name must not be empty! (" + GetClassType(classMap) + ": '" + classMap.Name + "')", "Table"); // do not localize
}
if (classMap.GetTableMap() == null)
{
HandleVerifyException(classMap, "Table not found! (" + GetClassType(classMap) + ": '" + classMap.Name + "', Table: '" + classMap.Table + "')", "Table"); // do not localize
}
if (classMap.TypeColumn.Length > 0)
{
if (classMap.GetTypeColumnMap() == null)
{
HandleVerifyException(classMap, "Type column not found! (" + GetClassType(classMap) + ": '" + classMap.Name + "', Type column: '" + classMap.TypeColumn + "')", "TypeColumn"); // do not localize
}
if (classMap.TypeValue.Length < 1)
{
HandleVerifyException(classMap, "Type column supplied but no type value! (" + GetClassType(classMap) + ": '" + classMap.Name + "', Type column: '" + classMap.TypeColumn + "')", "TypeColumn"); // do not localize
}
}
}
if (classMap.TypeValue.Length > 0)
{
if (classMap.TypeColumn.Length < 1)
{
HandleVerifyException(classMap, "Type value supplied but no type column! (" + GetClassType(classMap) + ": '" + classMap.Name + "', Type value: '" + classMap.TypeValue + "')", "TypeValue"); // do not localize
}
VerifyUniqueTypeValue(classMap);
}
}
if (classMap.InheritsClass.Length > 0)
{
if (superClassMap == null)
{
HandleVerifyException(classMap, "Inherited class not found! (" + GetClassType(classMap) + ": '" + classMap.Name + "', Inherited class: '" + classMap.InheritsClass + "')", "InheritsClass"); // do not localize
}
}
if (classMap.GetSortedIdentityPropertyMaps(ref failedSorting, true).Count < 1)
{
HandleVerifyException(classMap, "Class must have at least one identity property! (" + GetClassType(classMap) + ": '" + classMap.Name + "')", "PropertyMaps"); // do not localize
}
if (failedSorting)
{
HandleVerifyException(classMap, "Failed sorting identity properties due to invalid indexes! (" + GetClassType(classMap) + ": '" + classMap.Name + "')", "PropertyMaps"); // do not localize
}
if (classMap.IsInHierarchy())
{
if (classMap.InheritanceType == InheritanceType.None)
{
HandleVerifyException(classMap, "Inheritance type must be specified for class that is part of an inheritance hierarchy! (" + GetClassType(classMap) + ": '" + classMap.Name + "')", "InheritanceType"); // do not localize
}
else
{
if (classMap.InheritanceType == InheritanceType.ConcreteTableInheritance)
{
if (superClassMap != null)
{
if (!(classMap.IsAbstract))
{
foreach (IPropertyMap propertyMap in classMap.GetAllPropertyMaps())
{
//.........这里部分代码省略.........