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