public Task StartAsync(CancellationToken cancellationToken) { logger.LogInfo("Starting application as service!"); Process process = new Process(); process.StartInfo.FileName = configReader.GetValue("AppToStart"); var variables = configReader.ConfigValues; logger.LogInfo($"Variales count is: {variables.Count()}"); foreach (var item in variables) { if (item.Value != null) { process.StartInfo.EnvironmentVariables[item.Key] = item.Value; } } process.StartInfo.Arguments = FindMainJsFile(configReader.GetValue("StartupFile")); logger.LogInfo($"Process arguments: {process.StartInfo.Arguments}"); logger.LogInfo("Process starting..."); process.Start(); return(Task.CompletedTask); }
public static TEnum GetEnum <TEnum>(this IConfigReader configReader, string path, TEnum defaultValue = default(TEnum)) { var value = configReader.GetValue(path); return(value != null ? (TEnum)Enum.Parse(typeof(TEnum), configReader.GetValue(path)) : defaultValue); }
private Route InitializeRoutes(string routeName, int AllowedSpeed, string POT_HOLES_OFFSET_WEATHER_KEY) { return(new Route(routeName, AllowedSpeed, _configReader.GetValue <Int32>($"{routeName}_POTHOLES"), _configReader.GetValue <Int32>($"{routeName}_DISTANCE"), _configReader.GetValue <double>(POT_HOLES_OFFSET_WEATHER_KEY) )); }
public static TimeSpan GetTimeSpan(this IConfigReader configReader, string path, TimeSpan defaultValue = new TimeSpan()) { var value = configReader.GetValue(path); return(value != null ? TimeSpan.Parse(value) : defaultValue); }
public static bool GetBool(this IConfigReader configReader, string path, bool defaultValue = false) { var value = configReader.GetValue(path); return(value != null ? bool.Parse(value) : defaultValue); }
public static int GetInt32(this IConfigReader configReader, string path, int defaultValue = 0) { var value = configReader.GetValue(path); return(value != null ? int.Parse(value) : defaultValue); }
/// <summary> /// Gets configuration value of specified type, assuming its value serialized using JSON. /// Returns default value if specified value is not set. /// </summary> public static T GetJson <T>(this IConfigReader reader, string name, T defaultValue) { var value = reader.GetValue(name); if (value == null) { return(defaultValue); } return(ParseJson <T>(name, value)); }
public List <Vehicle> GetAvailableVehiclesForWeather(string weather) { List <Vehicle> vehicles = new List <Vehicle>(); List <string> availableVehicles = _configReader.GetValueCollection <string>(weather).Cast <string>().ToList(); foreach (var name in availableVehicles) { string MAX_SPEED_KEY = $"{name.ToUpper()}_SPEED"; string POTHOLE_SPEED_KEY = $"{name.ToUpper()}_SPEED_POTHOLE"; double MaxSpeed = _configReader.GetValue <double>(MAX_SPEED_KEY); double PotHoleSpeed = _configReader.GetValue <double>(POTHOLE_SPEED_KEY); Vehicle vehicle = new Vehicle(name, MaxSpeed, PotHoleSpeed); vehicles.Add(vehicle); } return(vehicles); }
/// <summary> /// Gets configuration value of specified type, assuming its value serialized using JSON. /// Throws exception if specified value is not set. /// </summary> public static T GetJson <T>(this IConfigReader reader, string name) { var value = reader.GetValue(name); if (value == null) { string message = $"Configuration parameter '{name}' is not found."; throw new ConfigurationErrorsException(message); } return(ParseJson <T>(name, value)); }
public AriaLogger(IConfigReader configReader, string tableName) { _tenantToken = configReader.GetValue("TenantToken"); _tableName = tableName; }
/// <summary> /// Checks whether specified configuration value is null or absent. /// </summary> public static bool IsNull(this IConfigReader reader, string name) { var value = reader.GetValue(name); return(value == null); }