Пример #1
0
            public virtual bool SupportsTargetMapping(ASTargetMappingDescriptor descriptor)
            {
                if (type.IsAssignableFrom(descriptor.SourceNativeType))
                {
                    return(true);
                }

                return(false);
            }
Пример #2
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);
        }
Пример #3
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);
        }
Пример #4
0
        /// <inheritdoc />
        public override IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            ActionScriptClassMapping classMapping = mappingTable.GetClassMappingByType(descriptor.SourceNativeType);

            if (classMapping != null)
            {
                return(new ObjectMapper(classMapping));
            }

            return(null);
        }
Пример #5
0
        /// <inheritdoc />
        public override IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            foreach (PrimitiveMapper mapper in mappers)
            {
                if (mapper.SupportsTargetMapping(descriptor))
                {
                    return(mapper);
                }
            }

            return(null);
        }
Пример #6
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);
        }
Пример #7
0
        /// <summary>
        /// Gets an ActionScript target mapper that satisfies the specified descriptor.
        /// </summary>
        /// <param name="descriptor">The target mapping descriptor</param>
        /// <returns>The ActionScript target mapper, or null if no compatible mapper can be obtained by any registered factory</returns>
        public IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
        {
            lock (syncRoot)
            {
                IASTargetMapper mapper;
                if (!targetMapperCache.TryGetValue(descriptor, out mapper))
                {
                    foreach (IASMapperFactory factory in mapperFactories)
                    {
                        mapper = factory.GetASTargetMapper(descriptor);
                        if (mapper != null)
                        {
                            break;
                        }
                    }

                    targetMapperCache.Add(descriptor, mapper);
                }

                return(mapper);
            }
        }
Пример #8
0
 public override bool SupportsTargetMapping(ASTargetMappingDescriptor descriptor)
 {
     return(descriptor.SourceNativeType.IsEnum);
 }
Пример #9
0
 /// <summary>
 /// Gets an ActionScript target mapper that satisfies the specified descriptor.
 /// </summary>
 /// <param name="descriptor">The target mapping descriptor</param>
 /// <returns>The ActionScript target mapper, or null if no compatible mapper can be obtained by this factory</returns>
 public virtual IASTargetMapper GetASTargetMapper(ASTargetMappingDescriptor descriptor)
 {
     return(null);
 }