{"action":"created","comment":{"url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments/28352179","id":28352179,"diff_hunk":"@@ -0,0 +1,53 @@\n+﻿namespace Our.Umbraco.Ditto\r\n+{\r\n+    using System;\r\n+    using System.ComponentModel;\r\n+    using System.Linq;\r\n+\r\n+    /// <summary>\r\n+    /// An extension of the <see cref=\"DittoConverter\"/> class which accepts an <see cref=\"System.Attribute\"/> as a generic type.\r\n+    /// </summary>\r\n+    /// <typeparam name=\"T\">An <see cref=\"System.Attribute\"/> type</typeparam>\r\n+    public abstract class DittoConverterWithAttribute<T> : DittoConverter where T : Attribute\r\n+    {\r\n+        /// <summary>\r\n+        /// Returns whether this converter can convert an object of the given type to the type of this converter, using the specified context.\r\n+        /// </summary>\r\n+        /// <param name=\"context\">An <see cref=\"T:System.ComponentModel.ITypeDescriptorContext\" /> that provides a format context.</param>\r\n+        /// <param name=\"sourceType\">A <see cref=\"T:System.Type\" /> that represents the type you want to convert from.</param>\r\n+        /// <returns>\r\n+        /// true if this converter can perform the conversion; otherwise, false.\r\n+        /// </returns>\r\n+        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)\r\n+        {\r\n+            if (context != null && context.PropertyDescriptor != null && context.PropertyDescriptor.Attributes != null)\r\n+            {\r\n+                return context.PropertyDescriptor.Attributes\r\n+                    .OfType<T>()\r\n+                    .Any();\r\n+            }\r\n+\r\n+            return base.CanConvertFrom(context, sourceType);\r\n+        }\r\n+\r\n+        /// <summary>\r\n+        /// Gets the attribute.\r\n+        /// </summary>\r\n+        /// <param name=\"context\">The context.</param>\r\n+        /// <returns></returns>\r\n+        public T GetAttribute(ITypeDescriptorContext context)\r","path":"src/Our.Umbraco.Ditto/ComponentModel/TypeConverters/DittoConverterWithAttribute.cs","position":38,"original_position":38,"commit_id":"b7a48060f379c3e23498e66c5eec911c5b870225","original_commit_id":"b7a48060f379c3e23498e66c5eec911c5b870225","user":{"login":"JimBobSquarePants","id":385879,"avatar_url":"https://avatars.githubusercontent.com/u/385879?v=3","gravatar_id":"","url":"https://api.github.com/users/JimBobSquarePants","html_url":"https://github.com/JimBobSquarePants","followers_url":"https://api.github.com/users/JimBobSquarePants/followers","following_url":"https://api.github.com/users/JimBobSquarePants/following{/other_user}","gists_url":"https://api.github.com/users/JimBobSquarePants/gists{/gist_id}","starred_url":"https://api.github.com/users/JimBobSquarePants/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JimBobSquarePants/subscriptions","organizations_url":"https://api.github.com/users/JimBobSquarePants/orgs","repos_url":"https://api.github.com/users/JimBobSquarePants/repos","events_url":"https://api.github.com/users/JimBobSquarePants/events{/privacy}","received_events_url":"https://api.github.com/users/JimBobSquarePants/received_events","type":"User","site_admin":false},"body":"protected virtual :wink: ","created_at":"2015-04-14T17:57:40Z","updated_at":"2015-04-14T17:57:40Z","html_url":"https://github.com/leekelleher/umbraco-ditto/pull/64#discussion_r28352179","pull_request_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64","_links":{"self":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments/28352179"},"html":{"href":"https://github.com/leekelleher/umbraco-ditto/pull/64#discussion_r28352179"},"pull_request":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64"}}},"pull_request":{"url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64","id":33266509,"html_url":"https://github.com/leekelleher/umbraco-ditto/pull/64","diff_url":"https://github.com/leekelleher/umbraco-ditto/pull/64.diff","patch_url":"https://github.com/leekelleher/umbraco-ditto/pull/64.patch","issue_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/64","number":64,"state":"open","locked":false,"title":"Umbraco Dictionary Value Converter","user":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"body":"Revisiting #18, #22 (and various comments in #36)\r\n\r\nCombining a custom attribute with a custom converter, we can populate a model's property with a value from an Umbraco dictionary-item.\r\n\r\nFor example...\r\n\r\n```csharp\r\n[UmbracoDictionaryValue(\"MyLabel\")]\r\n[TypeConverter(typeof(DittoDictionaryValueConverter))]\r\npublic string SomeLabel { get; set; }\r\n```\r\n\r\nThere are a couple of implementation decisions that I'd like to discuss with this PR...\r\n\r\n* The `DittoConverterWithAttribute` base/abstract converter.\r\n  * I did it this way, as I thought we could reuse it when we do a similar attribute/converter for Relations, (see #36)\r\n  * I'm not 100% happy with the naming. It should have \"Converter\" suffix, would \"DittoWithAttributeConverter\" make sense? :persevere:\r\n\r\n* I've ended up using `UmbracoHelper` within `DittoDictionaryValueConverter`, as the Umbraco core's `CultureDictionaryFactoryResolver` is marked as internal in v6.2.5 :weary: (I considered using `uQuery` static helper, but that's probably worse these days)\r\n\r\nOpen for comment and suggestions. Once we're happy with the approach, we can do similar for Relations.","created_at":"2015-04-14T15:05:04Z","updated_at":"2015-04-14T17:57:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"00d9c637120557759abaa9f827428f43c601cd32","assignee":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/leekelleher/umbraco-ditto/milestones/4","html_url":"https://github.com/leekelleher/umbraco-ditto/milestones/0.7.0","labels_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/milestones/4/labels","id":1004046,"number":4,"title":"0.7.0","description":"","creator":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":13,"state":"open","created_at":"2015-03-03T14:06:35Z","updated_at":"2015-04-14T15:05:04Z","due_on":"2015-04-23T23:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64/commits","review_comments_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64/comments","review_comment_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments{/number}","comments_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/64/comments","statuses_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/b7a48060f379c3e23498e66c5eec911c5b870225","head":{"label":"leekelleher:feature/dictionary-typeconverter","ref":"feature/dictionary-typeconverter","sha":"b7a48060f379c3e23498e66c5eec911c5b870225","user":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"repo":{"id":18762346,"name":"umbraco-ditto","full_name":"leekelleher/umbraco-ditto","owner":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leekelleher/umbraco-ditto","description":"Ditto - the friendly POCO mapper for Umbraco","fork":false,"url":"https://api.github.com/repos/leekelleher/umbraco-ditto","forks_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/forks","keys_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/teams","hooks_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/hooks","issue_events_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/events{/number}","events_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/events","assignees_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/assignees{/user}","branches_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/branches{/branch}","tags_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/tags","blobs_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/refs{/sha}","trees_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/{sha}","languages_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/languages","stargazers_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/stargazers","contributors_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/contributors","subscribers_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/subscribers","subscription_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/subscription","commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/commits{/sha}","git_commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/commits{/sha}","comments_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/comments{/number}","issue_comment_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/comments{/number}","contents_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/contents/{+path}","compare_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/merges","archive_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/downloads","issues_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues{/number}","pulls_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls{/number}","milestones_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/milestones{/number}","notifications_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/labels{/name}","releases_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/releases{/id}","created_at":"2014-04-14T13:52:54Z","updated_at":"2015-04-14T17:40:11Z","pushed_at":"2015-04-14T17:40:11Z","git_url":"git://github.com/leekelleher/umbraco-ditto.git","ssh_url":"git@github.com:leekelleher/umbraco-ditto.git","clone_url":"https://github.com/leekelleher/umbraco-ditto.git","svn_url":"https://github.com/leekelleher/umbraco-ditto","homepage":"http://our.umbraco.org/projects/developer-tools/ditto","size":7969,"stargazers_count":33,"watchers_count":33,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":5,"forks":12,"open_issues":5,"watchers":33,"default_branch":"develop"}},"base":{"label":"leekelleher:develop","ref":"develop","sha":"e13da59015c15a66bcccd427f1d0980bd25cb88b","user":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"repo":{"id":18762346,"name":"umbraco-ditto","full_name":"leekelleher/umbraco-ditto","owner":{"login":"leekelleher","id":209066,"avatar_url":"https://avatars.githubusercontent.com/u/209066?v=3","gravatar_id":"","url":"https://api.github.com/users/leekelleher","html_url":"https://github.com/leekelleher","followers_url":"https://api.github.com/users/leekelleher/followers","following_url":"https://api.github.com/users/leekelleher/following{/other_user}","gists_url":"https://api.github.com/users/leekelleher/gists{/gist_id}","starred_url":"https://api.github.com/users/leekelleher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leekelleher/subscriptions","organizations_url":"https://api.github.com/users/leekelleher/orgs","repos_url":"https://api.github.com/users/leekelleher/repos","events_url":"https://api.github.com/users/leekelleher/events{/privacy}","received_events_url":"https://api.github.com/users/leekelleher/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leekelleher/umbraco-ditto","description":"Ditto - the friendly POCO mapper for Umbraco","fork":false,"url":"https://api.github.com/repos/leekelleher/umbraco-ditto","forks_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/forks","keys_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/teams","hooks_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/hooks","issue_events_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/events{/number}","events_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/events","assignees_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/assignees{/user}","branches_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/branches{/branch}","tags_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/tags","blobs_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/refs{/sha}","trees_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/{sha}","languages_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/languages","stargazers_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/stargazers","contributors_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/contributors","subscribers_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/subscribers","subscription_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/subscription","commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/commits{/sha}","git_commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/git/commits{/sha}","comments_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/comments{/number}","issue_comment_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/comments{/number}","contents_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/contents/{+path}","compare_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/merges","archive_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/downloads","issues_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues{/number}","pulls_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls{/number}","milestones_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/milestones{/number}","notifications_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/labels{/name}","releases_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/releases{/id}","created_at":"2014-04-14T13:52:54Z","updated_at":"2015-04-14T17:40:11Z","pushed_at":"2015-04-14T17:40:11Z","git_url":"git://github.com/leekelleher/umbraco-ditto.git","ssh_url":"git@github.com:leekelleher/umbraco-ditto.git","clone_url":"https://github.com/leekelleher/umbraco-ditto.git","svn_url":"https://github.com/leekelleher/umbraco-ditto","homepage":"http://our.umbraco.org/projects/developer-tools/ditto","size":7969,"stargazers_count":33,"watchers_count":33,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":12,"mirror_url":null,"open_issues_count":5,"forks":12,"open_issues":5,"watchers":33,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64"},"html":{"href":"https://github.com/leekelleher/umbraco-ditto/pull/64"},"issue":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/64"},"comments":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/64/comments"},"review_comments":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64/comments"},"review_comment":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/64/commits"},"statuses":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/b7a48060f379c3e23498e66c5eec911c5b870225"}}}}