public override void ShowDialog(object sender, EventArgs e) { string[] files; string path; if (ConvDlg.Show("", GetOpenFilter(), out files, out path) == DialogResult.OK) { ProgressDlg pd = new ProgressDlg(DevStringTable.Instance["GUI:Converting"]); pd.MinVal = 0; pd.Value = 0; pd.MaxVal = files.Length; pd.Show(); string dest = Path.Combine(path, "color.ini"); ini = new IniConfiguration(); iniSect = new IniSection("Textures"); ini.Add(iniSect.Name, iniSect); for (int i = 0; i < files.Length; i++) { Convert(new DevFileLocation(files[i]), null); pd.Value = i; Application.DoEvents(); } pd.Close(); pd.Dispose(); ini.Save(dest); } }
private static object ParseValue(PropertyDescriptor pd, object value) { try { if (pd.Converter.CanConvertFrom(value.GetType())) { return(pd.Converter.ConvertFrom(value)); } if (pd.PropertyType == typeof(IniConfiguration)) { return(IniConfiguration.Parse(value.ToString())); } if (pd.PropertyType == typeof(StringCollection)) { StringCollection collection = new StringCollection(); if (value is string) { if (!CommonHelper.IsNullOrWhiteSpace(value.ToString())) { collection.AddRange(Regex.Split(value.ToString(), @"\s*\r?\n\s*")); } } else if (value is IEnumerable <string> ) { collection.AddRange(((IEnumerable <string>)value).ToArray()); } return(collection); } } catch (Exception ex) { SPDiagnosticsService.Local.WriteTrace(TraceCategory.SiteConfig, ex); } return(null); }
public GsmModem(ILog aLogger) { mLogger = aLogger; mConfig = new IniConfiguration(mLogger, "GsmModem.ini"); Operators = new CellOperators(); // add hardcoded operators AddOperators(); // add operator from config Hardware = new GsmHardware(aLogger); Session = new GprsSession(aLogger, Hardware, Operators); }
public IConfiguration GetConfiguration(string filePath, string fileName) { if (configurations == null) { configurations = new List <IniConfiguration>(); } foreach (IniConfiguration cfg in configurations) { if (cfg.FilePath == filePath && cfg.FileName == fileName) { return(cfg); } } IniConfiguration newCfg = new IniConfiguration(filePath, fileName); configurations.Add(newCfg); return(newCfg); }
private void Init() { try { mConfig = new IniConfiguration(mLogger, "GsmModem.ini"); // TODO: перенести конфигурацию пинов в INI файл mReset = new OutputPort(Pin.Gpio0_21, false); // 21 mDtr = new OutputPort(Pin.Gpio2_20, true); // 84 DataPort = new GsmChannel(mLogger, mConfig.GetString("Gprs", "DataPath")); DataPort.OnExecuteError += PowerOff; AuxPort = new GsmChannel(mLogger, mConfig.GetString("Gprs", "AuxPath")); } catch (ArgumentException) { } catch (IOException) { } catch (UnauthorizedAccessException) { } catch (NotSupportedException) { } catch (System.Security.SecurityException) { } }
private ConnectionSettings LoadConnectionSettings(IniConfiguration conf) { ConnectionSettings s = new ConnectionSettings(); // Server string server = conf["connection.server"]; if (String.IsNullOrWhiteSpace(server)) { Log(LogLevel.Error, "Connector: Server value is missing"); return null; } Log(LogLevel.Info, "Config: Server = " + server); s.ServerAddress = server; // Port string portin = conf["connection.port"]; if (String.IsNullOrWhiteSpace(portin)) { Log(LogLevel.Error, "Config: Port value is missing"); return null; } if (portin[0] == '+') { Log(LogLevel.Info, "Config: SSL is set"); s.UseSSL = true; portin = portin.Substring(1); } if (portin[0] == '+') { Log(LogLevel.Info, "Config: Will attempt to verify SSL"); s.UseSSLVerify = true; portin = portin.Substring(1); } int port; if (int.TryParse(portin, out port)) { if (port < 1 || port > 65535) { Log(LogLevel.Error, "Config: Port value is out of range"); return null; } Log(LogLevel.Info, "Config: Port = " + port); s.ServerPort = port; } else { Log(LogLevel.Error, "Config: Port value is invalid"); return null; } // Password string password = conf["connection.password"]; if (String.IsNullOrWhiteSpace(password)) { Log(LogLevel.Info, "Config: Server password not set"); } else { Log(LogLevel.Info, "Config: Server password set"); s.ServerPassword = password; } // Nick string nick = conf["connection.nick"]; if (string.IsNullOrWhiteSpace(nick)) { Log(LogLevel.Error, "Config: Nick value is missing"); return null; } Log(LogLevel.Info, "Config: Nick = " + nick); s.InitialNick = nick; // Ident string ident = conf["connection.ident"]; if (string.IsNullOrWhiteSpace(ident)) { Log(LogLevel.Error, "Config: Ident value is missing"); return null; } Log(LogLevel.Info, "Config: Ident = " + ident); s.Ident = ident; // Real name string realname = conf["connection.realname"]; if (string.IsNullOrWhiteSpace(realname)) { Log(LogLevel.Error, "Config: Real Name value is missing"); return null; } Log(LogLevel.Info, "Config: Real Name = " + realname); s.Realname = realname; return s; }
public static IServiceProvider Configure(IServiceCollection services) { var assemblyPath = Directory.GetCurrentDirectory(); var config = new IniConfiguration(Path.Combine(assemblyPath, "sir.ini")); // register config services.Add(new ServiceDescriptor(typeof(IConfigurationProvider), config)); // register plugin startup and teardown handlers #if DEBUG assemblyPath = Path.Combine(assemblyPath, "bin\\Debug\\netcoreapp2.1"); #endif var files = Directory.GetFiles(assemblyPath, "*.plugin.dll"); foreach (var assembly in files.Select(file => AssemblyLoadContext.Default.LoadFromAssemblyPath(file))) { foreach (var type in assembly.GetTypes()) { // search for concrete types if (!type.IsInterface) { var interfaces = type.GetInterfaces(); if (interfaces.Contains(typeof(IPluginStop))) { services.Add(new ServiceDescriptor(typeof(IPluginStop), type, ServiceLifetime.Singleton)); } else if (interfaces.Contains(typeof(IPluginStart))) { services.Add(new ServiceDescriptor(typeof(IPluginStart), type, ServiceLifetime.Singleton)); } } } } var plugins = new PluginsCollection(); services.Add(new ServiceDescriptor(typeof(PluginsCollection), plugins)); var serviceProvider = services.BuildServiceProvider(); // raise startup event foreach (var service in serviceProvider.GetServices <IPluginStart>()) { service.OnApplicationStartup(services, serviceProvider, config); } // Fetch one instance each of all plugins and register them with the PluginCollection // so that they can be fetched at runtime by Content-Type and System.Type. foreach (var service in services.BuildServiceProvider().GetServices <IWriter>()) { plugins.Add(service.ContentType, service); } foreach (var service in services.BuildServiceProvider().GetServices <IReader>()) { plugins.Add(service.ContentType, service); } RegisterComponents(services, plugins, services.BuildServiceProvider()); return(services.BuildServiceProvider()); }
private static void RegisterServices() { _serviceCollection.AddSingleton(provider => new Application()); _serviceCollection.AddSingleton(provider => IniConfiguration.ConfigurationBuilder(_serviceCollection, _pathToConfig)); }