Exemple #1
0
        /// <summary>
        /// Creates provider instances based on configuration.
        /// </summary>
        public void UpdateInstances()
        {
            if (!Instances.ContainsKey("Default"))
            {
                Instances["Default"] = new ProviderInstance(this, "Default");
            }

            string configPattern = $"LoggingProvider\\.{Name}\\.(.+)\\.Enabled";
            Regex  regex         = new Regex(configPattern, RegexOptions.IgnoreCase);

            foreach (string name in Configuration.ConfigurationHost.Configurations.Keys)
            {
                if (!regex.IsMatch(name))
                {
                    continue;
                }

                Match match = regex.Match(name);
                if (!Instances.ContainsKey(match.Groups[1].Value))
                {
                    Instances[match.Groups[1].Value] = new ProviderInstance(this, match.Groups[1].Value);
                }
            }

            bool enableState = false;

            if (Instances.Values.Where(o => o.Enabled).Count() > 0)
            {
                enableState = true;
            }
            Enabled = enableState;
        }
 /// <summary>
 /// Initializes a logging provider instance, creating the dynamic module needed and updating its metadata to reflect this change.
 /// </summary>
 /// <param name="Instance">The instance to initialize</param>
 internal static void InitializeProviderInstance(ProviderInstance Instance)
 {
     Utility.UtilityHost.ImportScriptBlock(ProviderV2ModuleScript);
     ProviderV2ModuleScript.Invoke(Instance);
 }