/// <summary> /// ConfigurationProvider constructor. /// </summary> /// <param name="traceId">A unique identifier used to correlate debugging and diagnostics messages.</param> /// <param name="serviceName">Name of the service.</param> /// <param name="context">CodePackageActivationContext instance.</param> /// <param name="logger">IServiceEventSource instance for logging.</param> /// <param name="configurationName">The name of the configuration to load. This will be appended to the name of the service when looking for the file (e.g. FrontEnd.Name.json)</param> public ConfigurationProvider(Guid traceId, Uri serviceName, ICodePackageActivationContext context, IServiceLogger logger, string configurationName = null) { if (serviceName == null) { throw new ArgumentNullException(nameof(serviceName)); } if (context == null) { throw new ArgumentNullException(nameof(context)); } if (logger == null) { throw new ArgumentNullException(nameof(logger)); } logger.Verbose(traceId, ComponentName, "Initializing."); this.serviceNameUri = serviceName; this.serviceName = this.serviceNameUri.Segments[this.serviceNameUri.Segments.Length - 1]; this.logger = logger; this.ConfigurationName = configurationName; // Subscribe to configuration change events if the context was passed. It will not be passed for unit tests. context.ConfigurationPackageAddedEvent += this.ConfigurationPackageAdded; context.ConfigurationPackageModifiedEvent += this.ConfigurationPackageModified; context.ConfigurationPackageRemovedEvent += this.ConfigurationPackageRemoved; // Create the add event parameters and call. var packageEvent = new PackageAddedEventArgs <ConfigurationPackage> { Package = context.GetConfigurationPackageObject(ConfigurationPackageObjectName) }; this.ConfigurationPackageAdded(null, packageEvent); logger.Verbose(traceId, ComponentName, "Finished initializing."); }