public void ReadXmlFromFile(string path, string fileName) { string filePath = Path.Combine(path, fileName);
XmlSerializer deserializer = new XmlSerializer(TipsProvider.TipsList.GetType()); TextReader textReader = null;
try { textReader = new StreamReader(filePath); TipsProvider.TipsList = (List<Entity.Tips>)deserializer.Deserialize(textReader); } catch(Exception e) { } finally { if (textReader != null) textReader.Close(); } }
But now I want to use this method to also read xml from anothe typeof object.The 3 bold lines is the objects that is "hard coded" in this method and should be generic.
How do i implement this?Should i implement some kind of pattern?
Br Morten