Esempio n. 1
0
 /// <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);
 }
Esempio n. 2
0
        /// <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;
        }
Esempio n. 3
0
 public static Serializer GetSerializer(Type type, SerializationContext context)
 {
     return new Serializer(type, context);
 }