/// <summary> /// Initializes a new instance of the <see cref="SerializationHandler"/> class. /// </summary> /// <param name="targetType">Target serialization type.</param> /// <param name="contractName">Serialization handler contract name.</param> /// <param name="id">Serialization handler ID.</param> protected SerializationHandler(Type targetType, string contractName, int id) { this.id = id; this.name = contractName; this.type = targetType; this.isImmutableType = Generator.IsImmutableType(targetType); }
private ISerializer <T> CreateWellKnownSerializer <T>() { Type type = typeof(T); if (!IsSerializable(type)) { return(new NonSerializer <T>()); } if (type.IsInterface) { return(null); } if (Generator.IsSimpleValueType(type)) { return(new SimpleSerializer <T>()); } if (Generator.IsImmutableType(type)) { return(new ImmutableSerializer <T>()); } if (type.IsValueType) { return(new StructSerializer <T>()); } if (type.IsClass) { return(new ClassSerializer <T>()); } throw new SerializationException("Don't know how to serialize objects of type " + type.FullName); }