Inheritance: IViewConfigSource
示例#1
0
 public IViewConfigSource GetAreaConfig(string areaName)
 {
     if (string.IsNullOrEmpty(areaName))
         return default(IViewConfigSource);
     var source = Config.Areas.SingleOrDefault(x => x.Name == areaName);
     var viewConfigSource = new ViewConfigSource {Config = source};
     return viewConfigSource;
 }
示例#2
0
        public static ViewConfigSource Create(string xmlSource)
        {
            if (!File.Exists(xmlSource))
                throw new FileNotFoundException(xmlSource);
            Stream stream = null;
            try
            {
                var serializer = new XmlSerializer(typeof(ViewConfigSchema));
                stream = new FileStream(xmlSource, FileMode.Open);
                var result = serializer.Deserialize(stream) as ViewConfigSchema;

                if(result == null)
                    throw new Exception("Unable to create ViewConfigSource out of the xml file.");

                var configSource = new ViewConfigSource {Config = result};
                return configSource;
            }
            finally
            {
                if (stream != null)
                    stream.Close();
            }
        }