コード例 #1
0
        public PluginSettings(object ParentSettingsClass) : base(ParentSettingsClass)
        {
            _settingsIo.WriteSettings = writer =>
            {
                writer.WriteStartElement("SettingsSerializer");
                ExportToXml(writer);
                writer.WriteEndElement();

                writer.Serialize(Playback);
                writer.Serialize(BaiduTtsSettings);
            };

            _settingsIo.ReadSettings = reader =>
            {
                switch (reader.LocalName)
                {
                case "SettingsSerializer":
                    ImportFromXml(reader);
                    break;

                case nameof(PlaybackSettings):
                    Playback = reader.Deserialize <PlaybackSettings>();
                    break;

                case nameof(BaiduTTSSettings):
                    BaiduTtsSettings = reader.Deserialize <BaiduTTSSettings>();
                    break;
                }
            };
        }
コード例 #2
0
        public void Load()
        {
            if (File.Exists(_settingsFile))
            {
                FileStream fs = new FileStream(_settingsFile, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);

                XmlTextReader reader = new XmlTextReader(fs);
                while (reader.Read())
                {
                    if (reader.NodeType != XmlNodeType.Element)
                    {
                        continue;
                    }

                    switch (reader.LocalName)
                    {
                    case "SettingsSerializer":
                        ImportFromXml(reader);
                        break;

                    case nameof(PlaybackSettings):
                        Playback = Deserialize <PlaybackSettings>(reader);
                        break;

                    case nameof(BaiduTTSSettings):
                        BaiduTtsSettings = Deserialize <BaiduTTSSettings>(reader);
                        break;
                    }
                }

                reader.Close();
            }
        }
コード例 #3
0
        public PluginSettings(object ParentSettingsClass) : base(ParentSettingsClass)
        {
            _settingsIo.WriteSettings = writer =>
            {
                writer.WriteStartElement("SettingsSerializer");
                ExportToXml(writer);
                writer.WriteEndElement();

                writer.Serialize(Playback);
                writer.Serialize(PreProcessorSettings);
                writer.Serialize(CafeTtsSettings);
                writer.Serialize(BaiduTtsSettings);
                writer.Serialize(SApi5Settings);
                writer.Serialize(BaipiaoSettings);
                writer.Serialize(EdgeTtsSettings);
                writer.Serialize(GoogleUnofficialTtsSettings);
                writer.Serialize(YoudaoTtsSettings);
                writer.Serialize(XfyunTtsSettings);
            };

            _settingsIo.ReadSettings = reader =>
            {
                switch (reader.LocalName)
                {
                case "SettingsSerializer":
                    ImportFromXml(reader);
                    break;

                case nameof(PlaybackSettings):
                    Playback = reader.Deserialize <PlaybackSettings>();
                    break;

                case nameof(preprocess.PreProcessorSettings):
                    PreProcessorSettings = reader.Deserialize <PreProcessorSettings>();
                    break;

                case nameof(CafeTTSSettings):
                    CafeTtsSettings = reader.Deserialize <CafeTTSSettings>();
                    break;

                case nameof(BaiduTTSSettings):
                    BaiduTtsSettings = reader.Deserialize <BaiduTTSSettings>();
                    BaiduTtsSettings.RemoveFreeKey();
                    break;

                case nameof(SAPI5Settings):
                    SApi5Settings = reader.Deserialize <SAPI5Settings>();
                    break;

                case nameof(engine.baipiao.BaipiaoSettings):
                    BaipiaoSettings = reader.Deserialize <BaipiaoSettings>();
                    break;

                case nameof(EdgeTTSSettings):
                    EdgeTtsSettings = reader.Deserialize <EdgeTTSSettings>();
                    break;

                case nameof(GoogleUnofficialTTSSettings):
                    GoogleUnofficialTtsSettings = reader.Deserialize <GoogleUnofficialTTSSettings>();
                    break;

                case nameof(YoudaoTTSSettings):
                    YoudaoTtsSettings = reader.Deserialize <YoudaoTTSSettings>();
                    break;

                case nameof(XfyunTTSSettings):
                    XfyunTtsSettings = reader.Deserialize <XfyunTTSSettings>();
                    break;
                }
            };
        }