コード例 #1
0
 private void Initialize(string kbCorePath)
 {
     if (_kcInstance == null)
     {
         if (!string.IsNullOrWhiteSpace(kbCorePath) && System.IO.File.Exists(kbCorePath))
         {
             try
             {
                 // Dynamicly load Keyboard_Core.dll and it's dependencies. Instantiate KeyboardControl class and cast it to a known interface.
                 var assembly     = Assembly.LoadFrom(kbCorePath);
                 var assemblyType = assembly.GetType("Keyboard_Core.KeyboardControl");
                 var instance     = Activator.CreateInstance(assemblyType);
                 _kcInstance = instance.ActLike <IBacklightControl>();
             }
             catch (Exception e)
             {
                 _logger.Error(e, "Unable to load Keyboard_Core.dll. Error:", 50903);
                 //_hub.PublishAsync(new StopServiceRequestMessage(this)); // Simply ignore this
                 return;
             }
         }
         else
         {
             _logger.Error("Unable to locate Keyboard_Core.dll.", 50903);
             //_hub.PublishAsync(new StopServiceRequestMessage(this)); // Simply ignore this
             return;
         }
     }
 }
コード例 #2
0
        private void Clear()
        {
            _kcInstance = null;

            _subToActivate?.Dispose();
            _subToActivate = null;
            _subToDeactivate?.Dispose();
            _subToDeactivate = null;
            _subToStop?.Dispose();
            _subToStop = null;
            _subToStart?.Dispose();
            _subToStart = null;
            _subToRequest?.Dispose();
            _subToRequest = null;
            StopChecker();
        }