{"action":"created","comment":{"url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/comments/42826746","id":42826746,"diff_hunk":"@@ -0,0 +1,99 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.ComponentModel;\n+using System.Runtime.CompilerServices;\n+using DotNetNuke.Common;\n+\n+namespace DotNetNuke.Entities.Modules.Settings\n+{\n+    public class StringBasedSettings : ISettingsStore\n+    {\n+        Dictionary<string, string> _cache;\n+        Dictionary<string, Action> _dirty;\n+        Func<string, string> _get;\n+        Action<string, string> _set;\n+\n+        /// <param name=\"get\">Function to get a value out of your setting store</param>\n+        /// <param name=\"set\">Action to save a value back to the setting store</param>\n+        public StringBasedSettings(Func<string, string> get, Action<string, string> set)\n+        {\n+            Requires.NotNull(\"Get\", get);\n+            Requires.NotNull(\"Set\", set);\n+\n+            _get = get;\n+            _set = set;\n+            _cache = new Dictionary<string, string>();\n+            _dirty = new Dictionary<string, Action>();\n+        }\n+\n+        // All changes to the settings are recorded and get only executed on demand \n+        public void Save()\n+        {\n+            foreach (var save in _dirty.Values) save();\n+            _dirty.Clear();\n+        }\n+\n+        // CallerMemberName is used for the name of the setting. No more magic strings\n+        public string Get(string @default = default(string), [CallerMemberName] string name = null)\n+        {\n+            Requires.NotNull(\"Name\", name);\n+\n+            if (_cache.ContainsKey(name))\n+            {\n+                return _cache[name];\n+            }\n+            else\n+            {\n+                var value = _get(name) ?? @default;\n+                _cache[name] = value;\n+                return value;\n+            }\n+        }\n+\n+        public T Get<T>(T @default = default(T), [CallerMemberName] string name = null)\n+        {\n+            //required to behave Get and Get<string> the same\n+            if (typeof(T) == typeof(string)) return (T)(object)Get((string)(object)@default, name);\n+\n+            var converter = TypeDescriptor.GetConverter(typeof(T));","path":"DNN Platform/Library/Entities/Modules/Settings/StringBasedSettings.cs","position":58,"original_position":58,"commit_id":"8db788fbeef857806cebe6d692fa0b3b75a9f02a","original_commit_id":"8db788fbeef857806cebe6d692fa0b3b75a9f02a","user":{"login":"bdukes","id":59507,"avatar_url":"https://avatars.githubusercontent.com/u/59507?v=3","gravatar_id":"","url":"https://api.github.com/users/bdukes","html_url":"https://github.com/bdukes","followers_url":"https://api.github.com/users/bdukes/followers","following_url":"https://api.github.com/users/bdukes/following{/other_user}","gists_url":"https://api.github.com/users/bdukes/gists{/gist_id}","starred_url":"https://api.github.com/users/bdukes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdukes/subscriptions","organizations_url":"https://api.github.com/users/bdukes/orgs","repos_url":"https://api.github.com/users/bdukes/repos","events_url":"https://api.github.com/users/bdukes/events{/privacy}","received_events_url":"https://api.github.com/users/bdukes/received_events","type":"User","site_admin":false},"body":"it needs to be possible to override the converter","created_at":"2015-10-23T01:50:52Z","updated_at":"2015-10-23T01:50:52Z","html_url":"https://github.com/dnnsoftware/Dnn.Platform/pull/904#discussion_r42826746","pull_request_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904","_links":{"self":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/comments/42826746"},"html":{"href":"https://github.com/dnnsoftware/Dnn.Platform/pull/904#discussion_r42826746"},"pull_request":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904"}}},"pull_request":{"url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904","id":48050449,"html_url":"https://github.com/dnnsoftware/Dnn.Platform/pull/904","diff_url":"https://github.com/dnnsoftware/Dnn.Platform/pull/904.diff","patch_url":"https://github.com/dnnsoftware/Dnn.Platform/pull/904.patch","issue_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/904","number":904,"state":"open","locked":false,"title":"Support for better settings management in modules","user":{"login":"donker","id":3319692,"avatar_url":"https://avatars.githubusercontent.com/u/3319692?v=3","gravatar_id":"","url":"https://api.github.com/users/donker","html_url":"https://github.com/donker","followers_url":"https://api.github.com/users/donker/followers","following_url":"https://api.github.com/users/donker/following{/other_user}","gists_url":"https://api.github.com/users/donker/gists{/gist_id}","starred_url":"https://api.github.com/users/donker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donker/subscriptions","organizations_url":"https://api.github.com/users/donker/orgs","repos_url":"https://api.github.com/users/donker/repos","events_url":"https://api.github.com/users/donker/events{/privacy}","received_events_url":"https://api.github.com/users/donker/received_events","type":"User","site_admin":false},"body":"To simplify module development we need better support for how we deal with settings. Too often developers use the bare bones hashtable that is in PortalModuleBase. This is \"dirty\" and can be done in a more concise way helping developers avoid errors in their code.\r\n\r\nThe code is the work of Stefan Cullman with review by Brian Dukes and myself.","created_at":"2015-10-19T09:47:59Z","updated_at":"2015-10-23T01:50:52Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7cc19983df8257dd43fed56e417a3e2162f22e14","assignee":null,"milestone":{"url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/milestones/10","html_url":"https://github.com/dnnsoftware/Dnn.Platform/milestones/8.0.0","labels_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/milestones/10/labels","id":881529,"number":10,"title":"8.0.0","description":"","creator":{"login":"jbrinkman","id":862921,"avatar_url":"https://avatars.githubusercontent.com/u/862921?v=3","gravatar_id":"","url":"https://api.github.com/users/jbrinkman","html_url":"https://github.com/jbrinkman","followers_url":"https://api.github.com/users/jbrinkman/followers","following_url":"https://api.github.com/users/jbrinkman/following{/other_user}","gists_url":"https://api.github.com/users/jbrinkman/gists{/gist_id}","starred_url":"https://api.github.com/users/jbrinkman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbrinkman/subscriptions","organizations_url":"https://api.github.com/users/jbrinkman/orgs","repos_url":"https://api.github.com/users/jbrinkman/repos","events_url":"https://api.github.com/users/jbrinkman/events{/privacy}","received_events_url":"https://api.github.com/users/jbrinkman/received_events","type":"User","site_admin":false},"open_issues":14,"closed_issues":231,"state":"open","created_at":"2014-11-26T15:34:06Z","updated_at":"2015-10-22T20:14:47Z","due_on":null,"closed_at":null},"commits_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904/commits","review_comments_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904/comments","review_comment_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/904/comments","statuses_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/statuses/8db788fbeef857806cebe6d692fa0b3b75a9f02a","head":{"label":"donker:DNN-7751-settings","ref":"DNN-7751-settings","sha":"8db788fbeef857806cebe6d692fa0b3b75a9f02a","user":{"login":"donker","id":3319692,"avatar_url":"https://avatars.githubusercontent.com/u/3319692?v=3","gravatar_id":"","url":"https://api.github.com/users/donker","html_url":"https://github.com/donker","followers_url":"https://api.github.com/users/donker/followers","following_url":"https://api.github.com/users/donker/following{/other_user}","gists_url":"https://api.github.com/users/donker/gists{/gist_id}","starred_url":"https://api.github.com/users/donker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donker/subscriptions","organizations_url":"https://api.github.com/users/donker/orgs","repos_url":"https://api.github.com/users/donker/repos","events_url":"https://api.github.com/users/donker/events{/privacy}","received_events_url":"https://api.github.com/users/donker/received_events","type":"User","site_admin":false},"repo":{"id":13046354,"name":"Dnn.Platform","full_name":"donker/Dnn.Platform","owner":{"login":"donker","id":3319692,"avatar_url":"https://avatars.githubusercontent.com/u/3319692?v=3","gravatar_id":"","url":"https://api.github.com/users/donker","html_url":"https://github.com/donker","followers_url":"https://api.github.com/users/donker/followers","following_url":"https://api.github.com/users/donker/following{/other_user}","gists_url":"https://api.github.com/users/donker/gists{/gist_id}","starred_url":"https://api.github.com/users/donker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/donker/subscriptions","organizations_url":"https://api.github.com/users/donker/orgs","repos_url":"https://api.github.com/users/donker/repos","events_url":"https://api.github.com/users/donker/events{/privacy}","received_events_url":"https://api.github.com/users/donker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/donker/Dnn.Platform","description":"DNN Corp Platform Repository.","fork":true,"url":"https://api.github.com/repos/donker/Dnn.Platform","forks_url":"https://api.github.com/repos/donker/Dnn.Platform/forks","keys_url":"https://api.github.com/repos/donker/Dnn.Platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/donker/Dnn.Platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/donker/Dnn.Platform/teams","hooks_url":"https://api.github.com/repos/donker/Dnn.Platform/hooks","issue_events_url":"https://api.github.com/repos/donker/Dnn.Platform/issues/events{/number}","events_url":"https://api.github.com/repos/donker/Dnn.Platform/events","assignees_url":"https://api.github.com/repos/donker/Dnn.Platform/assignees{/user}","branches_url":"https://api.github.com/repos/donker/Dnn.Platform/branches{/branch}","tags_url":"https://api.github.com/repos/donker/Dnn.Platform/tags","blobs_url":"https://api.github.com/repos/donker/Dnn.Platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/donker/Dnn.Platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/donker/Dnn.Platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/donker/Dnn.Platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/donker/Dnn.Platform/statuses/{sha}","languages_url":"https://api.github.com/repos/donker/Dnn.Platform/languages","stargazers_url":"https://api.github.com/repos/donker/Dnn.Platform/stargazers","contributors_url":"https://api.github.com/repos/donker/Dnn.Platform/contributors","subscribers_url":"https://api.github.com/repos/donker/Dnn.Platform/subscribers","subscription_url":"https://api.github.com/repos/donker/Dnn.Platform/subscription","commits_url":"https://api.github.com/repos/donker/Dnn.Platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/donker/Dnn.Platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/donker/Dnn.Platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/donker/Dnn.Platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/donker/Dnn.Platform/contents/{+path}","compare_url":"https://api.github.com/repos/donker/Dnn.Platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/donker/Dnn.Platform/merges","archive_url":"https://api.github.com/repos/donker/Dnn.Platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/donker/Dnn.Platform/downloads","issues_url":"https://api.github.com/repos/donker/Dnn.Platform/issues{/number}","pulls_url":"https://api.github.com/repos/donker/Dnn.Platform/pulls{/number}","milestones_url":"https://api.github.com/repos/donker/Dnn.Platform/milestones{/number}","notifications_url":"https://api.github.com/repos/donker/Dnn.Platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/donker/Dnn.Platform/labels{/name}","releases_url":"https://api.github.com/repos/donker/Dnn.Platform/releases{/id}","created_at":"2013-09-23T20:29:41Z","updated_at":"2014-05-02T21:46:02Z","pushed_at":"2015-10-19T09:47:17Z","git_url":"git://github.com/donker/Dnn.Platform.git","ssh_url":"git@github.com:donker/Dnn.Platform.git","clone_url":"https://github.com/donker/Dnn.Platform.git","svn_url":"https://github.com/donker/Dnn.Platform","homepage":null,"size":506705,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"dnnsoftware:development","ref":"development","sha":"736a5c9679f6ea2754a02e0c018893a01242a753","user":{"login":"dnnsoftware","id":5099054,"avatar_url":"https://avatars.githubusercontent.com/u/5099054?v=3","gravatar_id":"","url":"https://api.github.com/users/dnnsoftware","html_url":"https://github.com/dnnsoftware","followers_url":"https://api.github.com/users/dnnsoftware/followers","following_url":"https://api.github.com/users/dnnsoftware/following{/other_user}","gists_url":"https://api.github.com/users/dnnsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/dnnsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnnsoftware/subscriptions","organizations_url":"https://api.github.com/users/dnnsoftware/orgs","repos_url":"https://api.github.com/users/dnnsoftware/repos","events_url":"https://api.github.com/users/dnnsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/dnnsoftware/received_events","type":"Organization","site_admin":false},"repo":{"id":12095044,"name":"Dnn.Platform","full_name":"dnnsoftware/Dnn.Platform","owner":{"login":"dnnsoftware","id":5099054,"avatar_url":"https://avatars.githubusercontent.com/u/5099054?v=3","gravatar_id":"","url":"https://api.github.com/users/dnnsoftware","html_url":"https://github.com/dnnsoftware","followers_url":"https://api.github.com/users/dnnsoftware/followers","following_url":"https://api.github.com/users/dnnsoftware/following{/other_user}","gists_url":"https://api.github.com/users/dnnsoftware/gists{/gist_id}","starred_url":"https://api.github.com/users/dnnsoftware/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dnnsoftware/subscriptions","organizations_url":"https://api.github.com/users/dnnsoftware/orgs","repos_url":"https://api.github.com/users/dnnsoftware/repos","events_url":"https://api.github.com/users/dnnsoftware/events{/privacy}","received_events_url":"https://api.github.com/users/dnnsoftware/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dnnsoftware/Dnn.Platform","description":"DNN Corp Platform Repository.","fork":false,"url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform","forks_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/forks","keys_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/teams","hooks_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/hooks","issue_events_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/events{/number}","events_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/events","assignees_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/assignees{/user}","branches_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/branches{/branch}","tags_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/tags","blobs_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/git/refs{/sha}","trees_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/statuses/{sha}","languages_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/languages","stargazers_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/stargazers","contributors_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/contributors","subscribers_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/subscribers","subscription_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/subscription","commits_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/commits{/sha}","git_commits_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/git/commits{/sha}","comments_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/comments{/number}","issue_comment_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/comments{/number}","contents_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/contents/{+path}","compare_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/merges","archive_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/downloads","issues_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues{/number}","pulls_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls{/number}","milestones_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/milestones{/number}","notifications_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/labels{/name}","releases_url":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/releases{/id}","created_at":"2013-08-13T22:58:08Z","updated_at":"2015-10-16T23:39:53Z","pushed_at":"2015-10-22T20:14:47Z","git_url":"git://github.com/dnnsoftware/Dnn.Platform.git","ssh_url":"git@github.com:dnnsoftware/Dnn.Platform.git","clone_url":"https://github.com/dnnsoftware/Dnn.Platform.git","svn_url":"https://github.com/dnnsoftware/Dnn.Platform","homepage":null,"size":1265919,"stargazers_count":129,"watchers_count":129,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":170,"mirror_url":null,"open_issues_count":44,"forks":170,"open_issues":44,"watchers":129,"default_branch":"development"}},"_links":{"self":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904"},"html":{"href":"https://github.com/dnnsoftware/Dnn.Platform/pull/904"},"issue":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/904"},"comments":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/issues/904/comments"},"review_comments":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904/comments"},"review_comment":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/pulls/904/commits"},"statuses":{"href":"https://api.github.com/repos/dnnsoftware/Dnn.Platform/statuses/8db788fbeef857806cebe6d692fa0b3b75a9f02a"}}}}