コード例 #1
0
ファイル: OptionsControl.cs プロジェクト: Hexer10/SPCode
        public static OptionsControl Load(out bool ProgramIsNew)
        {
            try
            {
                if (File.Exists(Paths.GetOptionsFilePath()))
                {
                    object deserializedOptionsObj;
                    var    formatter = new BinaryFormatter();
                    using (var fileStream = new FileStream(Paths.GetOptionsFilePath(), FileMode.Open, FileAccess.Read,
                                                           FileShare.ReadWrite))
                    {
                        deserializedOptionsObj = formatter.Deserialize(fileStream);
                    }

                    var oc = (OptionsControl)deserializedOptionsObj;
                    oc.FillNullToDefaults();
                    ProgramIsNew = false;
                    return(oc);
                }
            }
            catch (Exception)
            {
            }

            var oco = new OptionsControl();

            oco.ReCreateCryptoKey();
#if DEBUG
            ProgramIsNew = false;
#else
            ProgramIsNew = true;
#endif
            return(oco);
        }