Ejemplo n.º 1
0
 public static SerializationAdapter GetAdapter(SerializationAdapterType type)
 {
     SerializationAdapter adapter = null;
     switch (type)
     {
         case SerializationAdapterType.XML:
             adapter = new XmlSerializer();
             break;
         case SerializationAdapterType.JSON:
             adapter = new JsonSerializer();
             break;
         default:
             throw new NotSupportedException("Incorrect adapter type");
     }
     return adapter;
 }
Ejemplo n.º 2
0
        public static SerializationAdapter GetAdapter(SerializationAdapterType type)
        {
            SerializationAdapter adapter = null;

            switch (type)
            {
            case SerializationAdapterType.XML:
                adapter = new XmlSerializer();
                break;

            case SerializationAdapterType.JSON:
                adapter = new JsonSerializer();
                break;

            default:
                throw new NotSupportedException("Incorrect adapter type");
            }
            return(adapter);
        }
Ejemplo n.º 3
0
        private static T GetObject <T>(string contents, SerializationAdapterType type)
        {
            var adapter = SerializationAdapter.GetAdapter(type);

            return((T)adapter.Deserialize(contents, typeof(T)));
        }