コード例 #1
0
        /// <summary>
        /// Adds environment variables to the application
        /// </summary>
        /// <param name="serviceCollection"></param>
        /// <param name="configureOptions"></param>
        /// <returns></returns>
        public static IServiceCollection AddEnvironment(this IServiceCollection serviceCollection, Action <EnvironmentOptions> configureOptions = null)
        {
            // configure environment variable options
            var options = new EnvironmentOptions();

            configureOptions?.Invoke(options);
            serviceCollection.AddSingleton(options);

            // add environment to the
            serviceCollection.TryAdd(ServiceDescriptor.Scoped <IEnvironment, Environment>());

            return(serviceCollection);
        }
コード例 #2
0
 /// <summary>
 /// Instantiates an <see cref="Environment"/>
 /// </summary>
 /// <param name="options"></param>
 public Environment(EnvironmentOptions options)
 {
     Options = options;
 }