/// <summary> /// Sets the current active log level for the configured logger /// </summary> /// <param name="configuration"></param> /// <param name="level">the log level to set</param> /// <returns></returns> public static IEnvironmentConfiguration WithLogLevel(this IEnvironmentConfiguration configuration, LogLevel level) { if (configuration.HasValue(typeof(ILoggerFacade).FullName)) { if (configuration.GetValue <ILoggerFacade>(typeof(ILoggerFacade).FullName) is ILoggerFacade facade) { facade.LogLevel = level; } } return(configuration); }
public static void Initialize(IEnvironmentConfiguration environmentConfiguration) { BluetoothConstants.ServiceUUID = environmentConfiguration.GetValue("BluetoothTracing_ServiceUUID"); BluetoothConstants.CharacteristicUUID = environmentConfiguration.GetValue("BluetoothTracing_CharacteristicUUID"); BluetoothConstants.DataExpirationTime = TimeSpan.FromDays(int.Parse(environmentConfiguration.GetValue("BluetoothTracing_DataExpirationTimeDays"))); BluetoothConstants.DeviceThrottleTime = TimeSpan.FromMinutes(int.Parse(environmentConfiguration.GetValue("BluetoothTracing_DeviceThrottleTimeMinutes"))); PushNotificationsConstants.SubscriptionTags = new string[] { environmentConfiguration.GetValue("PushNotifications_SubscriptionTags") }; PushNotificationsConstants.FCMTemplateBody = environmentConfiguration.GetValue("PushNotifications_FCMTemplateBody"); PushNotificationsConstants.APNTemplateBody = environmentConfiguration.GetValue("PushNotifications_APNTemplateBody"); }
/// <summary> /// Adds the xml file to the configuration. Multiple different files can be added. /// </summary> /// <param name="configuration"></param> /// <param name="file">the file to use</param> /// <param name="namespaces">The xml namespaces to load</param> /// <param name="eagerLoad">if the file should be eagerly loaded rather than lazily loaded</param> /// <returns></returns> public static IEnvironmentConfiguration WithXmlFile(this IEnvironmentConfiguration configuration, string file, IDictionary <string, string> namespaces = null, bool eagerLoad = false) { XmlFileParser parser = null; if (configuration.HasValue(typeof(XmlFileParser).FullName)) { parser = configuration.GetValue <XmlFileParser>(typeof(XmlFileParser).FullName); } else { configuration.SetValue(typeof(XmlFileParser).FullName, parser = new XmlFileParser()); } if (parser.Files.Keys.Any(x => String.Equals(x, file, StringComparison.OrdinalIgnoreCase))) { return(configuration); } else { var data = new XmlFileParser.FileDataHolder(); if (eagerLoad) { try { data.ParsedFile = XDocument.Parse(File.ReadAllText(file)); } catch { data.ParsingFailed = true; } } data.Path = file; if (namespaces != null && namespaces.Any()) { foreach (var keyValuePair in namespaces) { data.NamespaceManager.AddNamespace(keyValuePair.Key, keyValuePair.Value); } } parser.Files.Add(file, data); } return(configuration); }
/// <summary> /// Adds the json file to the configuration. Multiple different files can be added. /// Use root expression syntax for file selection <example>$(filename).some.path</example> /// </summary> /// <param name="configuration"></param> /// <param name="file">the file to use</param> /// <param name="eagerLoad">load the file eagerly instead of lazily</param> /// <returns></returns> public static IEnvironmentConfiguration WithJsonFile(this IEnvironmentConfiguration configuration, string file, bool eagerLoad = false) { JsonFileParser parser = null; if (configuration.HasValue(typeof(JsonFileParser).FullName)) { parser = configuration.GetValue <JsonFileParser>(typeof(JsonFileParser).FullName); } else { configuration.SetValue(typeof(JsonFileParser).FullName, parser = new JsonFileParser()); } if (parser.Files.Keys.Any(x => String.Equals(x, file, StringComparison.OrdinalIgnoreCase))) { return(configuration); } else { var data = new JsonFileParser.FileDataHolder(); if (eagerLoad) { try { data.ParsedFile = JsonManager.Parse(File.ReadAllText(file)); } catch { data.ParsingFailed = true; } } data.Path = file; parser.Files.Add(file, data); } return(configuration); }