예제 #1
0
        protected override object GetOrCreateDestinationObject(ResolutionContext context, IMappingEngineRunner mapper,
                                                               Type destElementType, int sourceLength)
        {
            var sourceArray = context.SourceValue as Array;

            if (sourceArray == null)
            {
                return(ObjectCreator.CreateArray(destElementType, sourceLength));
            }
            var destinationArray = ObjectCreator.CreateArray(destElementType, sourceArray);

            filler = new MultidimensionalArrayFiller(destinationArray);
            return(destinationArray);
        }
예제 #2
0
        public object Map(ResolutionContext context, IMappingEngineRunner mapper)
        {
            if (context.IsSourceValueNull && mapper.ShouldMapSourceCollectionAsNull(context))
            {
                return(null);
            }

            var sourceElementType = TypeHelper.GetElementType(context.SourceType);
            var destElementType   = TypeHelper.GetElementType(context.DestinationType);

            var sourceArray = (Array)context.SourceValue ?? ObjectCreator.CreateArray(sourceElementType, 0);

            var sourceLength = sourceArray.Length;
            var destArray    = ObjectCreator.CreateArray(destElementType, sourceLength);

            Array.Copy(sourceArray, destArray, sourceLength);

            return(destArray);
        }
예제 #3
0
 protected override object GetOrCreateDestinationObject(ResolutionContext context, IMappingEngineRunner mapper,
                                                        Type destElementType, int sourceLength)
 {
     return(ObjectCreator.CreateArray(destElementType, sourceLength));
 }