Skip to content

Commit

Permalink
Environment variables provider (#19)
Browse files Browse the repository at this point in the history
created provider with environment variables list
  • Loading branch information
salem84 authored Sep 21, 2021
1 parent f243ad6 commit 24d0eef
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
3 changes: 2 additions & 1 deletion samples/Basic/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public void ConfigureServices(IServiceCollection services)
.With<ClrVersionProvider>()
.With<AssemblyVersionProvider>()
.With<AppDomainAssembliesVersionProvider>()
.With<EnvironmentProvider>();
.With<EnvironmentProvider>()
.With<EnvironmentVariablesProvider>();
}

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AspNetCore.VersionInfo.Providers
{
public class EnvironmentVariablesProvider : IInfoProvider
{
public string Name => nameof(EnvironmentVariablesProvider);

public IDictionary<string, string> GetData()
{
var dict = new Dictionary<string, string>();

foreach (DictionaryEntry envVar in Environment.GetEnvironmentVariables())
{
dict.Add(envVar.Key.ToString(), envVar.Value.ToString());
}

return dict;
}
}
}

0 comments on commit 24d0eef

Please sign in to comment.