예제 #1
0
파일: ImportData.cs 프로젝트: xyyhqq/eXpand
        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);
            }
        }
예제 #2
0
파일: ImportData.cs 프로젝트: xyyhqq/eXpand
        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);
        }
예제 #3
0
파일: ImportData.cs 프로젝트: xyyhqq/eXpand
        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);
                    }
                }
            }
        }
예제 #4
0
 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);
 }
예제 #5
0
 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);
             }
         }
     }
 }
예제 #6
0
 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);
     }
 }