如何从自定义代码中检查 voice.mark-done-on-release 选项



在我们的工作区自定义中,我需要检查 voice.mark-done-on-release 选项是否设置为 true。使用反编译器,我可以看到此选项在 Genesyslab.Desktop.Modules.Voice.VoiceOptions 对象中作为属性 VoiceMarkDoneOnRelease 公开 - 但我如何才能做到这一点?

我可以看到我需要做的就是从 ConfigManager 中获取值,但最好引用公共属性,以便如果它发生变化,编译器就会知道它。

 namespace Genesyslab.Desktop.Modules.Voice
 {
     public class VoiceOptions : Options
     {
     ...
         public bool VoiceMarkDoneOnRelease
         {
             get
             {
                 return this.configManager.GetValueAsBoolean("voice.mark-done-on-release", false);
             }
         }

我能找到的最好的方法是注入IConfigManager并实例化您自己的VoiceOptions实例:

using Genesyslab.Desktop.Infrastructure.Configuration;
namespace YourNamespace
{
    public class YourClass
    {
        private readonly IConfigManager _genesysConfigManager;
        public CAMSessionService(IConfigManager genesysConfigManager)
        {
            _genesysConfigManager = genesysConfigManager;
        }
        private VoiceOptions GetVoiceOptions()
        {
            return VoiceOptions.CreateNewInstance(_genesysConfigManager);
        }
}

最新更新