Ejemplo n.º 1
0
 public override void actualizeInfo()
 {
     if (allcustomAttributes == null)
     {
         allcustomAttributes = new MapMembersInfo(toMapAttributeType, srcType, dstType);
     }
     allcustomAttributes.correspondentIndex();
 }
Ejemplo n.º 2
0
        public override object getMappedObject(object src)
        {
            allcustomAttributes = new MapMembersInfo(toMapAttributeType, srcType, dstType);
            allcustomAttributes.correspondentIndex();
            List <MatchInfo> listOfMembers = allcustomAttributes.listOfMembers;

            object ret = Activator.CreateInstance(dstType);


            foreach (MatchInfo indexs in listOfMembers)
            {
                int indexOfSrcFields = indexs.SrcIdx;
                int indexOfDstFields = indexs.DstIdx;


                if (indexs.MapperAux == null)
                {
                    SetMemberValue(allcustomAttributes.dstMemberInfo[indexOfDstFields], ret, GetMemberValue(allcustomAttributes.srcMemberInfo[indexOfSrcFields], src));
                }
                else
                {
                    if (GetUnderlyingType(allcustomAttributes.srcMemberInfo[indexOfSrcFields]).IsArray&& GetUnderlyingType(allcustomAttributes.dstMemberInfo[indexOfDstFields]).IsArray)
                    {
                        object[] srcO = (object[])GetMemberValue(allcustomAttributes.srcMemberInfo[indexOfSrcFields], src);

                        object ins = indexs.MapperAux.Map(srcO);

                        SetMemberValue(allcustomAttributes.dstMemberInfo[indexOfDstFields], ret, ins);
                    }
                    else
                    {
                        object srcO = GetMemberValue(allcustomAttributes.srcMemberInfo[indexOfSrcFields], src);

                        object ins = indexs.MapperAux.Map(srcO);

                        SetMemberValue(allcustomAttributes.dstMemberInfo[indexOfDstFields], ret, ins);
                    }
                }
            }

            return(ret);
        }