{"id":22800152,"url":"https://github.com/programystic/webconfighelper","last_synced_at":"2025-03-30T19:18:09.567Z","repository":{"id":144136449,"uuid":"168751175","full_name":"programystic/WebConfigHelper","owner":"programystic","description":"Helper methods to access the web config app settings","archived":false,"fork":false,"pushed_at":"2019-03-01T13:45:40.000Z","size":1791,"stargazers_count":1,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"develop","last_synced_at":"2025-03-06T21:16:16.965Z","etag":null,"topics":["appsettings","csharp","strongly-typed","web-config"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/programystic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-01T19:41:49.000Z","updated_at":"2019-03-01T13:45:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"7f2b86ec-2cd6-4973-8b6f-0d455e24ce9d","html_url":"https://github.com/programystic/WebConfigHelper","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programystic%2FWebConfigHelper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programystic%2FWebConfigHelper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programystic%2FWebConfigHelper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/programystic%2FWebConfigHelper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/programystic","download_url":"https://codeload.github.com/programystic/WebConfigHelper/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246365643,"owners_count":20765549,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["appsettings","csharp","strongly-typed","web-config"],"created_at":"2024-12-12T07:11:30.156Z","updated_at":"2025-03-30T19:18:09.323Z","avatar_url":"https://github.com/programystic.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Web.Config AppSettings Helper\n\n[![Build status](https://programystic.visualstudio.com/WebConfigHelper/_apis/build/status/WebConfigHelper-.NET%20Desktop-CI)](https://programystic.visualstudio.com/WebConfigHelper/_build/latest?definitionId=11)\n\n[![NuGet package](https://img.shields.io/nuget/v/WebConfigHelper.svg)](https://nuget.org/packages/WebConfigHelper)\n\nWebConfigHelper allows you to get strongly typed appsetting values from the web.config file.\n\n## Getting a setting:\n```cs\nvar config = new WebConfigValues();\n\nvar appVersion = config.GetAppSetting\u003cint\u003e(\"appVersion\");\nvar releaseDate = config.GetAppSetting\u003cDateTime\u003e(\"releaseDate\");\nvar appName = config.GetAppSetting\u003cstring\u003e(\"appName\");\n\n// Return a comma separated list as an array\n// \u003cadd key=\"versions\" value=\"1, 9, 15, 23\" /\u003e\n// \u003cadd key=\"keyDates\" value=\"01/02/2019, 01/03/2019, 01/04/2019\" /\u003e\n// \u003cadd key=\"names\" value=\"Fred, Sarah, Sam\" /\u003e\nvar versions = config.GetAppSettingArray\u003cint\u003e(\"versions\");\nvar keyDates = config.GetAppSettingArray\u003cDateTime\u003e(\"keyDates\");\nvar names = config.GetAppSettingArray\u003cstring\u003e(\"names\");\n\n// with a default value\nvar appVersion = config.GetAppSetting(\"appVersion\", 1);\nvar releaseDate = config.GetAppSettingArray\u003cDateTime\u003e(\"releaseDate\", DateTime.Parse(\"01/01/2000\");\nvar versions = config.GetAppSettingArray(\"versions\", new int[] { 1, 2 });\nvar keyDates = config.GetAppSettingArray(\"keyDates\", new int[] {  DateTime.Parse(\"01/01/2000\"),  DateTime.Parse(\"01/01/2001\") });\n```\n\n## Handling null values\n```cs\n// Either use a default value\nvar timeout = config.GetAppSetting(\"timeout\", 30);\n\n// or use a nullable type\nvar timeout = config.GetAppSetting\u003cint?\u003e(\"timeout\");\n\n// otherwise it will fail\nvar timeout = config.GetAppSetting\u003cint\u003e(\"timeout\");\n// System.ArgumentNullException : Setting 'timeout' returned null and type System.Int32 cannot have a null value\n```\n\n## Setting up a unit test (using Moq)\nWhen you are creating unit tests for your web application, you can mock IWebConfigProvider allowing you to test different app settings values.\n\n```cs\nvar provider = new Mock\u003cIWebConfigProvider\u003e();\n// GetAppSetting always returns a string value\nprovider.Setup(x =\u003e x.GetAppSetting(\"appVersion\")).Returns(\"1\");\nprovider.Setup(x =\u003e x.GetAppSetting(\"versions\")).Returns(\"1, 9, 15, 23\");\n\nvar config = new WebConfigValues(provider.Object);\nvar appVersion = config.GetAppSetting\u003cint\u003e(\"appVersion\");\nvar versions = config.GetAppSettingArray\u003cint\u003e(\"versions\");\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramystic%2Fwebconfighelper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprogramystic%2Fwebconfighelper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprogramystic%2Fwebconfighelper/lists"}