7 namespace SiliconStudio.AssemblyProcessor
15 private readonly
Type genericSerializableType;
16 private readonly
bool checkInterfaces;
18 protected Func<TypeReference, TypeReference> CreateSerializer {
get; set; }
22 this.genericSerializableType = genericSerializableType;
23 CreateSerializer = createSerializer;
24 checkInterfaces = genericSerializableType.IsInterface;
28 : this(genericSerializableType, (type => genericSerializerType.MakeGenericType(((GenericInstanceType)type).
GenericArguments.ToArray())))
30 if (genericSerializerType == null)
31 throw new ArgumentNullException(
"genericSerializerType");
32 if (genericSerializableType == null)
33 throw new ArgumentNullException(
"genericSerializableType");
36 #region IDataSerializerFactory Members
42 if (objectType.IsGenericInstance && checkInterfaces)
44 if (objectType.GetElementType().Resolve().Interfaces.Any(x => x.IsGenericInstance && x.GetElementType().FullName == genericSerializableType.FullName))
45 return CreateSerializer(objectType);
47 if (objectType.IsGenericInstance && objectType.GetElementType().FullName == genericSerializableType.FullName)
48 return CreateSerializer(objectType);
Gives the specified serializer type constructed with generic arguments of the serialized type...
The generic arguments of the serialized type will be passed as a generic arguments of the serializer...
The type of the serialized type will be passed as a generic arguments of the serializer. Example: serializer of A becomes instantiated as Serializer{A}.
virtual TypeReference GetSerializer(TypeReference objectType)
Gets the serializer type from a given object type.
Gives the required generic serializer for a given type. This is useful for generation of serializatio...
CecilGenericSerializerFactory(Type genericSerializableType, TypeReference genericSerializerType)