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;
 }
Exemple #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);
        }
Exemple #3
0
        private static T GetObject <T>(string contents, SerializationAdapterType type)
        {
            var adapter = SerializationAdapter.GetAdapter(type);

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