/// <summary> /// Adds the keyboard actuator to the list of actuators. This /// actuator is bundled with the SDK. /// </summary> private void addKeyboardActuatorToCache() { var attr = DescriptorAttribute.GetDescriptor(typeof(InputActuators.KeyboardActuator)); if (attr != null) { addActuatorToCache(attr.Id, typeof(InputActuators.KeyboardActuator)); } }
/// <summary> /// Gets the ACAT descriptor guid for the specifed Type /// </summary> /// <param name="type">Scanner class Type</param> /// <returns>The descirptor guid</returns> internal static Guid GetFormId(Type type) { var descAttribute = DescriptorAttribute.GetDescriptor(type); Guid retVal = Guid.Empty; if (descAttribute != null) { retVal = descAttribute.Id; } return(retVal); }
/// <summary> /// Finds engine by the specified name /// </summary> /// <param name="name">name of the engine</param> /// <returns>The engine</returns> public Guid GetByName(String name) { foreach (var type in Collection) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (String.Compare(descriptor.Name, name, true) == 0) { return(descriptor.Id); } } return(Guid.Empty); }
/// <summary> /// Returns the ID of the spellchecker by looking /// up the spellCheckerName of the spellchecker /// </summary> /// <param spellCheckerName="spellCheckerName">name to check</param> /// <returns>the spellchecker id, Empty if not found</returns> public Guid GetByName(String spellCheckerName) { foreach (var type in _spellCheckersTypeCache.Values) { var descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && String.Compare(descriptor.Name, spellCheckerName, true) == 0) { Log.Debug("Found spellchecker [" + spellCheckerName + "]"); return(descriptor.Id); } } Log.Debug("Could not find spellchecker for [" + spellCheckerName + "]"); return(Guid.Empty); }
/// <summary> /// Returns the ID of the WordPredictor with the /// specified name /// </summary> /// <param name="name">name of the word predictor</param> /// <returns>ID of the word predictor</returns> public Guid GetByName(String name) { foreach (Type type in _wordPredictorsTypeCache.Values) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && String.Compare(descriptor.Name, name, true) == 0) { Log.Debug("Found word predictor [" + name + "]"); return(descriptor.Id); } } Log.Debug("Could not find word predictor for [" + name + "]"); return(Guid.Empty); }
/// <summary> /// Looks up the cache for the specified GUID and returns the Type /// </summary> /// <param name="guid"></param> /// <returns></returns> public Type Lookup(Guid guid) { foreach (Type type in _wordPredictorsTypeCache.Values) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && Equals(guid, descriptor.Id)) { Log.Debug("Found word predictor of type " + type); return(type); } } Log.Debug("Could not find word predictor for id " + guid.ToString()); return(null); }
/// <summary> /// Gets the TTSEngine class Type correspoding to the guid /// </summary> /// <param name="guid"></param> /// <returns></returns> public Type this[Guid guid] { get { foreach (var type in Collection) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && Guid.Equals(guid, descriptor.Id)) { Log.Debug("Found TTS engine of type " + type); return(type); } } Log.Debug("Could not find TTS engine for id " + guid.ToString()); return(null); } }
/// <summary> /// Looks up the cache for the specified GUID and returns the Type /// </summary> /// <param name="guid"></param> /// <returns></returns> public Type Lookup(Guid guid) { if (Equals(guid, NullTTSEngine.Descriptor.Id)) { return(typeof(NullTTSEngine)); } foreach (Type type in Collection) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && Equals(guid, descriptor.Id)) { Log.Debug("Found TTS Engine of type " + type); return(type); } } Log.Debug("Could not find TTS Engine for id " + guid); return(null); }
/// <summary> /// Looks up the cache for the specified GUID and returns the Type /// </summary> /// <param name="guid"></param> /// <returns></returns> public Type Lookup(Guid guid) { if (Equals(guid, NullWordPredictor.Descriptor.Id)) { return(typeof(NullWordPredictor)); } foreach (Type type in Collection) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(type); if (descriptor != null && Equals(guid, descriptor.Id)) { Log.Debug("Found word predictor of type " + type); return(type); } } Log.Debug("Could not find word predictor for id " + guid.ToString()); return(null); }
/// <summary> /// Callback function for the directory walker. called whenever /// it finds a DLL /// </summary> /// <param name="dllName"></param> private void onFileFound(String dllName) { try { var inputActuatorsAssembly = Assembly.LoadFrom(dllName); foreach (Type type in inputActuatorsAssembly.GetTypes()) { if (typeof(ActuatorBase).IsAssignableFrom(type)) { var attr = DescriptorAttribute.GetDescriptor(type); if (attr != null && attr.Id != Guid.Empty) { addActuatorToCache(attr.Id, type); } } } } catch (Exception ex) { Log.Debug("Could not get types from assembly " + dllName + ". Exception : " + ex.ToString()); } }
/// <summary> /// Callback function for the directory walker. When a DLL is found, /// looks for all the TTSEngine types in the DLL and caches the GUID and /// the class type for the engine /// </summary> /// <param name="dllName">name of the DLL to load</param> private void onFileFound(String dllName) { try { var ttsEngineAssembly = Assembly.LoadFile(dllName); foreach (var type in ttsEngineAssembly.GetTypes()) { if (typeof(ITTSEngine).IsAssignableFrom(type)) { var attr = DescriptorAttribute.GetDescriptor(type); if (attr != null && attr.Id != Guid.Empty) { addEngineTypeToCache(attr.Id, type); } } } } catch (Exception ex) { Log.Debug("Could get types from assembly " + dllName + ". Exception : " + ex); } }
/// <summary> /// Call back function for when it finds a DLL. Load the dll and /// look for spell checker types in there. If found, add them to the cache /// </summary> /// <param name="dllName">Full path to the dll</param> private void onFileFound(String dllName) { try { var wordPredictorAssembly = Assembly.LoadFile(dllName); foreach (var type in wordPredictorAssembly.GetTypes()) { if (typeof(ISpellChecker).IsAssignableFrom(type)) { var attr = DescriptorAttribute.GetDescriptor(type); if (attr != null && attr.Id != Guid.Empty) { Add(attr.Id, _dirWalkCurrentCulture, type); } } } } catch (Exception ex) { Log.Debug("Could get types from assembly " + dllName + ". Exception : " + ex); } }
/// <summary> /// Call back function for when it finds a DLL. Load the dll and /// look for word predictor types in there. If found, add them to the cache /// </summary> /// <param name="dllName"></param> private void onFileFound(String dllName) { try { Assembly wordPredictorAssembly = Assembly.LoadFile(dllName); foreach (Type type in wordPredictorAssembly.GetTypes()) { if (typeof(IWordPredictor).IsAssignableFrom(type)) { DescriptorAttribute attr = DescriptorAttribute.GetDescriptor(type); if (attr != null && attr.Id != Guid.Empty) { Add(attr.Id, type); } } } } catch (Exception ex) { Log.Debug("Could get types from assembly " + dllName + ". Exception : " + ex.ToString()); } }
/// <summary> /// Call back function for when it finds a DLL. Load the dll and /// look for TTS Engine types in there. If found, add them to the cache /// </summary> /// <param name="dllName">name of the dll found</param> private void onFileFound(String dllName) { try { Assembly ttsEngineAssembly = Assembly.LoadFile(dllName); foreach (Type type in ttsEngineAssembly.GetTypes()) { if (typeof(ITTSEngine).IsAssignableFrom(type)) { DescriptorAttribute attr = DescriptorAttribute.GetDescriptor(type); if (attr != null && attr.Id != Guid.Empty) { Add(attr.Id, _dirWalkCurrentCulture, type); } } } } catch (Exception ex) { Log.Debug("Could get types from assembly " + dllName + ". Exception : " + ex.ToString()); } }
/// <summary> /// Returns the ID of the TTS Engine that supports the /// specified culture info. If no culture-specific /// TTS Engine is found, Guid.Empty is returned /// </summary> /// <param name="ci">culture info</param> /// <returns>ID of the TTS Engine</returns> public Guid GetDefaultByCulture(CultureInfo ci) { Tuple <String, Type> foundTuple = null; // first look for culture-specific TTS Engines foreach (var tuple in _ttsEnginesTypeCache.Values) { if (ci == null) { if (String.IsNullOrEmpty(tuple.Item1)) { foundTuple = tuple; break; } } else if (!String.IsNullOrEmpty(tuple.Item1) && (String.Compare(tuple.Item1, ci.Name, true) == 0) || String.Compare(tuple.Item1, ci.TwoLetterISOLanguageName, true) == 0) { foundTuple = tuple; break; } } if (foundTuple != null) { IDescriptor descriptor = DescriptorAttribute.GetDescriptor(foundTuple.Item2); if (descriptor != null) { Log.Debug("Found TTS Engine for culture " + (ci != null ? ci.Name : "Neutral") + "[" + descriptor.Name + "]"); return(descriptor.Id); } } return(Guid.Empty); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public SwitchWindowsAgent() { Name = DescriptorAttribute.GetDescriptor(GetType()).Name; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public VolumeSettingsAgent() { Name = DescriptorAttribute.GetDescriptor(GetType()).Name; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public SwitchWindowsAgent() { Name = DescriptorAttribute.GetDescriptor(GetType()).Name; initProperties(); }
/// <summary> /// Loads actuator settigns from the settings file. /// Walks through the extensions dirs, looks for actuators in there /// and caches the Types of the actuators. /// Configures the actuators with the settings from the settings file. /// Also if any acutators were discovered that are not in the settings file, /// adds them to the settings file and saves it. /// </summary> /// <param name="extensionDirs">directories to walk through</param> /// <param name="configFile">name of the actuators settings file</param> /// <param name="loadAll">whether to load even the disabled actuators</param> /// <returns>true on success</returns> public bool Load(IEnumerable <String> extensionDirs, String configFile, bool loadAll = false) { addKeyboardActuatorToCache(); foreach (string dir in extensionDirs) { String extensionDir = dir + "\\" + ActuatorManager.ActuatorsRootDir; loadActuatorTypesIntoCache(extensionDir); } if (!File.Exists(configFile)) { return(false); } ActuatorConfig.ActuatorSettingsFileName = configFile; Config = ActuatorConfig.Load(); // walk through the settings file create and configure // actuators foreach (var actuatorSetting in Config.ActuatorSettings) { try { bool enabled = (loadAll) || actuatorSetting.Enabled; if (enabled && (actuatorSetting.Id != Guid.Empty)) { if (!_actuatorsTypeCache.ContainsKey(actuatorSetting.Id)) { continue; } var type = _actuatorsTypeCache[actuatorSetting.Id]; if (type != null) { var assembly = Assembly.LoadFrom(type.Assembly.Location); var actuator = (IActuator)assembly.CreateInstance(type.FullName); if (actuator != null) { actuator.OnRegisterSwitches(); actuator.Load(actuatorSetting.SwitchSettings); actuator.Enabled = actuatorSetting.Enabled; var actuatorEx = new ActuatorEx(actuator); _actuatorsEx.Add(actuatorEx); _actuators.Add(actuator); } } } } catch (Exception ex) { Log.Exception(ex); } } // now go through all the actuators that are not in the // settings file and add them to the settings file bool isDirty = false; foreach (var actuatorType in _actuatorsTypeCache.Values) { var attr = DescriptorAttribute.GetDescriptor(actuatorType); if (attr != null && attr.Id != Guid.Empty) { var actuatorSetting = Config.Find(attr.Id); if (actuatorSetting != null) { continue; } try { var assembly = Assembly.LoadFrom(actuatorType.Assembly.Location); var actuator = (IActuator)assembly.CreateInstance(actuatorType.FullName); if (actuator != null) { var actuatorEx = new ActuatorEx(actuator); _actuatorsEx.Add(actuatorEx); _actuators.Add(actuator); actuatorSetting = new ActuatorSetting(attr.Name, attr.Id); Config.ActuatorSettings.Add(actuatorSetting); actuator.OnRegisterSwitches(); actuator.Load(actuatorSetting.SwitchSettings); isDirty = true; } } catch (Exception ex) { Log.Exception(ex); } } } if (isDirty) { Config.Save(); } return(true); }