private static SiteCollections OpenAndRead(string fileName) { SiteCollections sites = new SiteCollections(); try { if (!string.IsNullOrEmpty(fileName) && System.IO.File.Exists(fileName)) { // Create the serializer var serializer = new XmlSerializer(typeof(SiteCollections)); // Open config file using (var stream = new System.IO.StreamReader(fileName)) { // De-serialize the XML sites = serializer.Deserialize(stream) as SiteCollections; } } } catch (Exception ex) { throw new Exception("Can't read the configuration, 'Recent Sites' is empty.", ex); } return(sites); }
private static void Write(string fileName, SiteCollections sites) { if (!string.IsNullOrEmpty(fileName)) { // Create the serializer var serializer = new XmlSerializer(typeof(SiteCollections)); // Open config file using (var stream = new System.IO.StreamWriter(fileName)) { // Serialize the XML serializer.Serialize(stream, sites); } } }
static Globals() { SiteCollections = new SiteCollections(); CustomFeatureDefinitions = new FeatureCollection(); }