/// <summary>Reads template container from stream.</summary>
 /// <param name="stream">template stream.</param>
 /// <returns></returns>
 public static TemplateContainer ReadStream(Stream stream)
 {
     var serializer = new TemplateContainerSerializer();
     try {
         string xml;
         using (var reader = new StreamReader(stream)) {
             xml = reader.ReadToEnd();
             reader.Close();
         }
         return serializer.Deserialize(xml);
     } catch {}
     return new TemplateContainer();
 }
 /// <summary>Reads config data from config file.</summary>
 /// <param name="file">Config file name.</param>
 /// <returns></returns>
 public static TemplateContainer ReadFile(string file)
 {
     TemplateContainerSerializer serializer = new TemplateContainerSerializer();
     try {
         string xml = string.Empty;
         using (StreamReader reader = new StreamReader(file)) {
             xml = reader.ReadToEnd();
             reader.Close();
         }
         return serializer.Deserialize(xml);
     } catch {}
     return new TemplateContainer();
 }
Ejemplo n.º 3
0
        /// <summary>Reads template container from stream.</summary>
        /// <param name="stream">template stream.</param>
        /// <returns></returns>
        public static TemplateContainer ReadStream(Stream stream)
        {
            TemplateContainerSerializer serializer = new TemplateContainerSerializer();

            try {
                string xml = string.Empty;
                using (StreamReader reader = new StreamReader(stream)) {
                    xml = reader.ReadToEnd();
                    reader.Close();
                }
                return(serializer.Deserialize(xml));
            } catch {}
            return(new TemplateContainer());
        }