コード例 #1
0
 /// <summary>
 ///     Serialize our data members to our storage backing.
 ///     Currently configured to store to a JSON file.
 /// </summary>
 public static void Serialize(ATCSSettings atcsSettings)
 {
     using (FileStream settingsFile = new FileStream(
                SettingsFilePath, FileMode.OpenOrCreate, FileAccess.Write))
     {
         if (settingsFile != null)
         {
             DataContractJsonSerializer serializer =
                 new DataContractJsonSerializer(typeof(ATCSSettings));
             serializer.WriteObject(settingsFile, atcsSettings);
         }
     }
 }
コード例 #2
0
ファイル: ATCSLogFile.cs プロジェクト: erben22/atcsLogManager
        /// <summary>
        ///     Constructor.
        /// </summary>
        /// <param name="path">Fully qualified path to an ATCS log file.</param>
        public ATCSLogFile(string path)
        {
            filePath = path;

            // Attempt to obtain settings from a persisted settings file.
            // If the settings do not exist, create a default settings object
            // and use that.

            try
            {
                settings = ATCSSettingsSerializer.Deserialize();
            }
            catch (FileNotFoundException)
            {
                settings = new ATCSSettings();
            }
        }