Ejemplo n.º 1
0
        /// <summary>
        /// Load the file
        /// </summary>
        /// <typeparam name="T">Type of the project class</typeparam>
        /// <param name="path">Path to load</param>
        /// <returns>Instance of the loaded project class</returns>
        public static T Load <T>(string path) where T : BaseProject
        {
            BaseProject project = null;

            using (XmlTextReader reader = new XmlTextReader(path))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                project = (BaseProject)serializer.Deserialize(reader);
            }
            return((T)project);
        }
Ejemplo n.º 2
0
        public static T Load <T>(string path, XmlSchema schema) where T : BaseProject
        {
            BaseProject       project  = null;
            XmlReaderSettings settings = new XmlReaderSettings();

            settings.CheckCharacters = true;
            settings.Schemas.Add(schema);
            settings.ValidationType = ValidationType.Schema;
            using (XmlReader reader = XmlReader.Create(path, settings))
            {
                XmlSerializer serializer = new XmlSerializer(typeof(T));
                project = (BaseProject)serializer.Deserialize(reader);
            }
            return((T)project);
        }