Пример #1
0
        /// <inheritdoc />
        public override IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            Type[] genericTypeArgs = MappingUtils.GetGenericDictionaryTypeArgs(descriptor.SourceNativeType);
            if (genericTypeArgs != null)
            {
                return((IASTargetMapper)MappingUtils.InvokeGenericMethod(genericTypeArgs, getMapperInstance, new object[] { null }));
            }

            return(null);
        }
Пример #2
0
        /// <inheritdoc />
        public override IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            if (descriptor.SourceNativeType.IsArray && descriptor.SourceNativeType.GetArrayRank() == 1)
            {
                Type[] genericTypes = new Type[] { descriptor.SourceNativeType.GetElementType() };
                return((IASTargetMapper)MappingUtils.InvokeGenericMethod(genericTypes, getMapperInstance, EmptyArray <object> .Instance));
            }

            return(null);
        }
Пример #3
0
        /// <inheritdoc />
        public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor)
        {
            if ((descriptor.SourceKind == ASTypeKind.Array || descriptor.SourceKind == ASTypeKind.ByteArray) &&
                (descriptor.SourceContentFlags & ASValueContentFlags.HasDynamicProperties) == 0 &&
                descriptor.TargetNativeType.IsArray)
            {
                Type[] genericTypes = new Type[] { descriptor.TargetNativeType.GetElementType() };
                return((IASSourceMapper)MappingUtils.InvokeGenericMethod(genericTypes, getMapperInstance, EmptyArray <object> .Instance));
            }

            return(null);
        }
Пример #4
0
        /// <inheritdoc />
        public override IASSourceMapper GetASSourceMapper(ASSourceMappingDescriptor descriptor)
        {
            if ((descriptor.SourceKind == ASTypeKind.Array || descriptor.SourceKind == ASTypeKind.Object) &&
                (descriptor.SourceContentFlags & ASValueContentFlags.HasIndexedValues) == 0)
            {
                Type[] genericTypeArgs = MappingUtils.GetGenericDictionaryTypeArgs(descriptor.TargetNativeType);
                if (genericTypeArgs != null)
                {
                    return((IASSourceMapper)MappingUtils.InvokeGenericMethod(genericTypeArgs, getMapperInstance, new object[] { descriptor.TargetNativeType }));
                }
            }

            return(null);
        }
Пример #5
0
        /// <inheritdoc />
        public override IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            // Note: We don't want to map arrays or dictionaries here.  Leave that up to a
            //       specialized implementation instead.
            if (!descriptor.SourceNativeType.IsArray &&
                !MappingUtils.IsGenericDictionary(descriptor.SourceNativeType))
            {
                Type[] genericTypeArgs = MappingUtils.GetGenericCollectionTypeArgs(descriptor.SourceNativeType);
                if (genericTypeArgs != null)
                {
                    return((IASTargetMapper)MappingUtils.InvokeGenericMethod(genericTypeArgs, getMapperInstance,
                                                                             new object[] { null }));
                }
            }

            return(null);
        }