void ImportSimpleProperty(UnitOfWork outputUow, UnitOfWork inputUow, InputMemberInfo memberInfo, ImportedMemberInfo importedMemberInfo, object objectToImport, object xpoObject) { XPMemberInfo xpMemberInfo = importedMemberInfo.MemberInfo; if (xpMemberInfo != null) { var value = xpMemberInfo.GetValue(objectToImport); if (memberInfo.ReferenceType != null && memberInfo.ReferenceType.IsPersistent) { var memberType = ((InputObjectClassInfo)memberInfo.ReferenceType).OutputClassInfo.ClassType; bool returnKey; bool returnImportKey; value = GetReferenceMemberValue(outputUow, value, memberType, out returnKey, out returnImportKey); if (returnKey) { AddFillRefInfo(memberInfo, xpoObject, value); return; } if (returnImportKey) { value = inputUow.GetKeyValue(value); AddFillRefAndImportInfo(memberInfo, xpoObject, value); return; } } memberInfo.SetOutputMemberValue(xpoObject, value); } }
void AddFillRefAndImportInfo(InputMemberInfo memberInfo, object owner, object refImportKey) { FillRefList fillRefsList; if (!_fillRefsAndImportDictionary.TryGetValue(memberInfo, out fillRefsList)) { fillRefsList = new FillRefList(); _fillRefsAndImportDictionary.Add(memberInfo, fillRefsList); } fillRefsList.OwnerList.Add(owner); fillRefsList.RefKeyList.Add(refImportKey); }
void ImportManyToManyCollection(UnitOfWork outputUow, UnitOfWork intputUow, object xpoObject, ImportedMemberInfo importedMemberInfo, object objectToImport, InputMemberInfo memberInfo) { if (!importedMemberInfo.InitialData.DataProvider) { return; } var xpClassInfo = intputUow.Dictionary.GetClassInfo(null, importedMemberInfo.InitialData.DataProviderTableName); var criteriaOperator = CriteriaOperator.Parse(importedMemberInfo.InitialData.DataProviderQueryColumnName + "=?", objectToImport); using (var xpCollection = new XPCollection(intputUow, xpClassInfo, criteriaOperator)) { var collection = (XPBaseCollection)memberInfo.GetValue(xpoObject); var dataProviderResultInfo = xpClassInfo.GetMember(importedMemberInfo.InitialData.DataProviderResultColumnName); foreach (var o in xpCollection) { var listElementTypeInfo = memberInfo.CollectionElementType; var memberValue = dataProviderResultInfo.GetValue(o); bool returnKey; bool returnImportKey; var referenceMemberValue = GetReferenceMemberValue(outputUow, memberValue, listElementTypeInfo.ClassType, out returnKey, out returnImportKey); if (returnKey) { AddFillRefInfo(memberInfo, xpoObject, referenceMemberValue); } if (returnImportKey) { AddFillRefAndImportInfo(memberInfo, xpoObject, referenceMemberValue); } else { collection.BaseAdd(referenceMemberValue); } } } }
void AddFillRefInfo(InputMemberInfo memberInfo, object owner, object refKey) { FillRefList fillRefsList; if (!_fillRefsDictionary.TryGetValue(memberInfo, out fillRefsList)) { fillRefsList = new FillRefList(); _fillRefsDictionary.Add(memberInfo, fillRefsList); } fillRefsList.OwnerList.Add(owner); fillRefsList.RefKeyList.Add(refKey); }
void ImportManyToManyCollection(UnitOfWork outputUow, UnitOfWork intputUow, object xpoObject, ImportedMemberInfo importedMemberInfo, object objectToImport, InputMemberInfo memberInfo) { if (!importedMemberInfo.InitialData.DataProvider) return; var xpClassInfo = intputUow.Dictionary.GetClassInfo(null, importedMemberInfo.InitialData.DataProviderTableName); var criteriaOperator = CriteriaOperator.Parse(importedMemberInfo.InitialData.DataProviderQueryColumnName + "=?", objectToImport); using (var xpCollection = new XPCollection(intputUow, xpClassInfo, criteriaOperator)) { var collection = (XPBaseCollection)memberInfo.GetValue(xpoObject); var dataProviderResultInfo = xpClassInfo.GetMember(importedMemberInfo.InitialData.DataProviderResultColumnName); foreach (var o in xpCollection) { var listElementTypeInfo = memberInfo.CollectionElementType; var memberValue = dataProviderResultInfo.GetValue(o); bool returnKey; bool returnImportKey; var referenceMemberValue = GetReferenceMemberValue(outputUow, memberValue, listElementTypeInfo.ClassType, out returnKey, out returnImportKey); if (returnKey) { AddFillRefInfo(memberInfo, xpoObject, referenceMemberValue); } if (returnImportKey) { AddFillRefAndImportInfo(memberInfo, xpoObject, referenceMemberValue); } else { collection.BaseAdd(referenceMemberValue); } } } }