コード例 #1
0
ファイル: NailsConfig.cs プロジェクト: 1upD/Nails
        /**
         * Static method to write Nails configuration to a file
         * <author>1upD</author>
         */
        public static void WriteConfiguration(string filepath, NailsConfig config)
        {
            try
            {
                log.Info(string.Format("Writing Nails configuration to file: {0}", filepath));

                XmlSerializer serializer = new XmlSerializer(typeof(NailsConfig));

                StreamWriter writer = new StreamWriter(filepath);
                serializer.Serialize(writer, config);
                writer.Close();
            }
            catch (Exception e)
            {
                log.Error(string.Format("Error writing Nails configuration to file: {0}", filepath), e);
            }
        }
コード例 #2
0
ファイル: NailsConfig.cs プロジェクト: 1upD/Nails
        /**
         * Static method to read configuration from an XML file and return a NailsConfig object.
         * <author>1upD</author>
         */
        public static NailsConfig ReadConfiguration(string filepath)
        {
            NailsConfig config = null;

            try
            {
                log.Info(string.Format("Loading Nails configuration from file: {0}", filepath));
                XmlSerializer serializer = new XmlSerializer(typeof(NailsConfig));

                StreamReader reader = new StreamReader(filepath);
                config = (NailsConfig)serializer.Deserialize(reader);
                reader.Close();
            }
            catch (Exception e)
            {
                log.Error(string.Format("Error reading Nails configuration in file: {0}", filepath), e);
            }

            return(config);
        }