/// <summary> /// Static configuration loader /// </summary> /// <param name="serializer"></param> /// <param name="fileName"></param> /// <returns></returns> protected static TConfig Current(IConfigSerializer serializer, string fileName) { var serialized = LoadFromFile(fileName); if (string.IsNullOrEmpty(serialized)) { return(default(TConfig)); } return(serializer.DeserializeObject <TConfig>(serialized)); }
private T Import(string data) { try { var o = _serializer.DeserializeObject <T>(data); return(string.IsNullOrEmpty(data) ? null : o); } catch (InvalidOperationException exception) { throw new InvalidOperationException("Can't deserialize current configuration.", exception); } }