/// <summary> /// Adds the interface. /// </summary> /// <returns>The interface.</returns> /// <param name="domain">Domain.</param> /// <param name="assemblyName">Assembly name.</param> public MigInterface AddInterface(string domain, string assemblyName = "") { MigInterface migInterface = GetInterface(domain); if (migInterface == null) { Type type = null; try { type = TypeLookup("MIG.Interfaces." + domain, assemblyName); if (type == null) { Log.Error("Can't find type for Mig Interface with domain {0} (assemblyName={1})", domain, assemblyName); return(null); } migInterface = (MigInterface)Activator.CreateInstance(type); } catch (Exception e) { Log.Error(e); } if (migInterface != null) { var interfaceVersion = VersionLookup(type.Assembly); Log.Debug("Adding Interface {0} Version: {1}", migInterface.GetDomain(), interfaceVersion); Interfaces.Add(migInterface); migInterface.InterfaceModulesChanged += MigService_InterfaceModulesChanged; migInterface.InterfacePropertyChanged += MigService_InterfacePropertyChanged; } } // Try loading interface settings from MIG configuration var config = configuration.GetInterface(domain); if (config == null) { config = new Interface { Domain = domain }; if (config.Options == null) { config.Options = new List <Option>(); } configuration.Interfaces.Add(config); } if (migInterface != null) { Log.Debug("Setting Interface options"); migInterface.Options = config.Options; foreach (var opt in config.Options) { migInterface.SetOption(opt.Name, opt.Value); } } return(migInterface); }
/// <summary> /// Adds the interface. /// </summary> /// <returns>The interface.</returns> /// <param name="domain">Domain.</param> /// <param name="assemblyName">Assembly name.</param> public MigInterface AddInterface(string domain, string assemblyName = "") { MigInterface migInterface = GetInterface(domain); if (migInterface == null) { try { var type = TypeLookup("MIG.Interfaces." + domain, assemblyName); migInterface = (MigInterface)Activator.CreateInstance(type); } catch (Exception e) { MigService.Log.Error(e); } if (migInterface != null) { Log.Debug("Adding Interface {0}", migInterface.GetDomain()); Interfaces.Add(migInterface); migInterface.InterfaceModulesChanged += MigService_InterfaceModulesChanged; migInterface.InterfacePropertyChanged += MigService_InterfacePropertyChanged; } } // Try loading interface settings from MIG configuration var config = configuration.GetInterface(domain); if (config == null) { config = new Interface(); config.Domain = domain; if (config.Options == null) { config.Options = new List <Option>(); } configuration.Interfaces.Add(config); } if (migInterface != null) { Log.Debug("Setting Interface options"); migInterface.Options = config.Options; foreach (var opt in config.Options) { migInterface.SetOption(opt.Name, opt.Value); } } return(migInterface); }