示例#1
0
        /// <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));
        }
示例#2
0
 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);
     }
 }