Exemplo n.º 1
0
        private void FillReferenceData(IListReadOnly src, IList dest)
        {
            var i = 0;

            foreach (var srcitem in src)
            {
                if (dest[i] == null)
                {
                    var newElement = _elementTypeMap.CreateDestInstance(srcitem);
                    dest[i] = newElement;
                }
                else
                {
                    _elementTypeMap.SynchInstances(srcitem, dest[i]);
                }

                i++;
            }
        }
Exemplo n.º 2
0
        public override void FillData(object srcInstance, object destInstance)
        {
            var srcValue = _srcPropertyInfo.GetValue(srcInstance, null);

            if (srcValue == null)
            {
                _destPropertyInfo.SetValue(destInstance, null, null);
                return;
            }

            var destValue = _destPropertyInfo.GetValue(destInstance, null);

            if (destValue == null)
            {
                destValue = _typeMap.CreateDestInstance(srcValue);
                _destPropertyInfo.SetValue(destInstance, destValue, null);
            }
            else
            {
                _typeMap.SynchInstances(srcValue, destValue);
            }
        }
Exemplo n.º 3
0
        public override void SynchInstances(object srcInstance, object destInstance)
        {
            var srcList = SourceArrayList.Create(srcInstance);

            if (srcList == null)
            {
                throw new ExceptionOfMapping("Somehow appears that the class " + srcInstance.GetType() + " without IList interface tried to map to the array class (ArrayTypeMapper.SynchInstances)");
            }


            var destList = destInstance == null?_destArrayConstructor.Invoke(srcList) : destInstance as IList;

            if (destList == null)
            {
                throw new ExceptionOfMapping("Somehow appears that the dest class for source class" + srcInstance.GetType() + " without IList interface tried to map to the array class (ArrayTypeMapper.SynchInstances)");
            }

            var i = 0;

            foreach (var itm in srcList)
            {
                destList[i++] = _arrayItemMap.CreateDestInstance(itm);
            }
        }