예제 #1
0
        private static void Copy()
        {
            // Create new file.
            IniFile file = new IniFile();

            // Add new content.
            IniSection section = file.Sections.Add("Section");
            IniKey     key     = section.Keys.Add("Key");

            // Add duplicate section.
            file.Sections.Add(section.Copy());

            // Add duplicate key.
            section.Keys.Add(key.Copy());

            // Create new file.
            IniFile newFile = new IniFile(new IniOptions());

            // Import first file's section to second file.
            newFile.Sections.Add(section.Copy(newFile));
        }
예제 #2
0
        private void Patcher_PatcherCompleted(object sender, PatcherCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                Logger.Debug($"{sender.ToString()} cancelled");
                DeleteTmpFiles(e.Language);
            }
            else if (e.Error != null)
            {
                Logger.Error(e.Error);
                MsgBox.Error(Methods.ExeptionParser(e.Error));
                DeleteTmpFiles(e.Language);
            }
            else
            {
                Logger.Debug($"{sender.ToString()} successfuly completed");

                string clientIniPath = Path.Combine(UserSettings.GamePath, Strings.IniName.ClientVer);
                if (!Methods.LoadVerIni(out IniFile clientIni, clientIniPath))
                {
                    throw new Exception(StringLoader.GetText("exception_generic_read_error", clientIniPath));
                }
                IniSection clientVerSection = clientIni.Sections[Strings.IniName.Ver.Section];

                string translationIniPath = Path.Combine(e.Language.Path, Strings.IniName.Translation);
                var    translationIni     = new IniFile();

                IniKey     translationDateKey        = new IniKey(translationIni, Strings.IniName.Patcher.KeyDate, Methods.DateToString(e.Language.LastUpdate));
                IniSection translationPatcherSection = new IniSection(translationIni, Strings.IniName.Patcher.Section, translationDateKey);

                translationIni.Sections.Add(translationPatcherSection);
                translationIni.Sections.Add(clientVerSection.Copy(translationIni));
                Logger.Debug($"Saving translation config to [{translationIniPath}]");
                translationIni.Save(translationIniPath);
            }

            SWFileManager.DisposeFileData();
            GC.Collect();
            this.CurrentState = State.Idle;
        }