Esempio n. 1
0
        public static void Save()
        {
            JObject json = new JObject
            {
                { "LanguageOverride", LanguageOverride.ToString() },
                { "LastProfile", LastProfile },
                { "UpdateGumpVersion", UpdateGumpVersion?.ToString() ?? "0.0.0.0" },
                { "AutoBackupProfiles", AutoBackupProfiles },
                { "AutoBackupProfilesDays", AutoBackupProfilesDays },
                { "AutoBackupProfilesDirectory", AutoBackupProfilesDirectory },
                { "AutoBackupProfilesLast", AutoBackupProfilesLast },
                { "SavePasswords", SavePasswords },
                { "SavePasswordsOnlyBlank", SavePasswordsOnlyBlank },
                { "UserId", UserId },
                { "UseCUOClilocLanguage", UseCUOClilocLanguage },
#if !DEVELOP
                { "WindowWidth", WindowWidth },
                { "WindowHeight", WindowHeight },
#endif
            };

            JArray linkedProfilesArray = new JArray();

            foreach (JObject linkedObj in _linkedProfiles.Select(profile =>
                                                                 new JObject {
                { "Serial", profile.Key }, { "Profile", profile.Value }
            }))
            {
                linkedProfilesArray.Add(linkedObj);
            }

            json.Add("Profiles", linkedProfilesArray);

            JArray savedPasswordsArray = new JArray();

            foreach (KeyValuePair <string, string> kvp in SavedPasswords)
            {
                savedPasswordsArray.Add(new JObject
                {
                    { "Username", kvp.Key }, { "Password", Crypter.Encrypt(kvp.Value) }
                });
            }

            json.Add("SavedPasswords", savedPasswordsArray);

            JArray assembliesArray = new JArray();

            foreach (string assembly in Assemblies ?? new string[0])
            {
                assembliesArray.Add(assembly);
            }

            json.Add("Assemblies", assembliesArray);

            File.WriteAllText(Path.Combine(Engine.StartupPath ?? Environment.CurrentDirectory, "Assistant.json"),
                              json.ToString(Formatting.Indented));
        }
        public static void Save()
        {
            JObject json = new JObject
            {
                { "LanguageOverride", LanguageOverride.ToString() },
                { "LastProfile", LastProfile },
                { "UpdateGumpVersion", UpdateGumpVersion?.ToString() ?? "0.0.0.0" }
            };

            JArray linkedProfilesArray = new JArray();

            foreach ( JObject linkedObj in _linkedProfiles.Select( profile =>
                new JObject { { "Serial", profile.Key }, { "Profile", profile.Value } } ) )
            {
                linkedProfilesArray.Add( linkedObj );
            }

            json.Add( "Profiles", linkedProfilesArray );

            File.WriteAllText( Path.Combine( Engine.StartupPath ?? Environment.CurrentDirectory, "Assistant.json" ),
                json.ToString( Formatting.Indented ) );
        }