コード例 #1
0
        public static void SaveConfiguration <P>(IConfiguration configuration, string filePath)
        {
            var serializer = new GenericSerializer <P>();

            using (TextWriter textWriter = File.CreateText(filePath))
            {
                serializer.Serialize(textWriter, configuration);
            }
        }
コード例 #2
0
        public static P LoadConfiguration <P>(string filePath)
        {
            var serializer = new GenericSerializer <P>();

            using (TextReader textReader = File.OpenText(filePath))
            {
                P loadedConfig = (P)serializer.Deserialize(textReader);
                return(loadedConfig);
            }
        }