/// <summary> /// Constructs a serializer to (de)serialize the given type using the /// specified configuration section. /// </summary> /// <param name="t">the type to serialize/deserialize</param> public Serializer(Type type, string configSection) { if (type == null) throw new ArgumentNullException("type"); _serializedType = type; _context = new SerializationContext(); _context.SerializerInstance = this; XmlConfigurator.Configure(_context, configSection); }
/// <summary> /// Constructs a serializer with an existing context to (de)serialize the given type /// </summary> /// <param name="t">the type to serialize/deserialize</param> /// <param name="context"></param> public Serializer(Type type, SerializationContext context) { if (type == null) throw new ArgumentNullException("type"); if (context == null) throw new ArgumentNullException("context"); _serializedType = type; _context = context; _context.SerializerInstance = this; }
public static Serializer GetSerializer(Type type, SerializationContext context) { return new Serializer(type, context); }