{"action":"created","comment":{"url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments/26004979","id":26004979,"diff_hunk":"@@ -90,5 +92,33 @@ public static IEnumerable<Type> GetBaseTypes(this Type type)\n                 type = type.BaseType;\n             }\n         }\n+\n+        /// <summary>\n+        /// Gets a all Type instances matching the specified class name with just non-namespace qualified class name.\n+        /// </summary>\n+        /// <param name=\"className\">Name of the class sought.</param>\n+        /// <param name=\"baseType\"></param>\n+        /// <returns>Types that have the class name specified. They may not be in the same namespace.</returns>\n+        public static IEnumerable<Type> GetTypeByName(string className, Type baseType)\n+        {\n+            /* [ML] - Look away kids, forgive me. We could improve performance with an optional app setting to filter assemblies \n+             * but this method executes in low milliseconds, hopefully with caching of these results we'll be ok\n+             */\n+\n+            var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(i => !i.FullName.ToLower().StartsWith(\"system\") && !i.FullName.ToLower().StartsWith(\"microsoft\") && !i.FullName.ToLower().StartsWith(\"windows\")).ToList();","path":"src/Our.Umbraco.Ditto/Extensions/TypeInferenceExtensions.cs","position":34,"original_position":34,"commit_id":"616a71f5638bc6a385d4b24d6866c1843957b793","original_commit_id":"616a71f5638bc6a385d4b24d6866c1843957b793","user":{"login":"micklaw","id":5840134,"avatar_url":"https://avatars.githubusercontent.com/u/5840134?v=3","gravatar_id":"","url":"https://api.github.com/users/micklaw","html_url":"https://github.com/micklaw","followers_url":"https://api.github.com/users/micklaw/followers","following_url":"https://api.github.com/users/micklaw/following{/other_user}","gists_url":"https://api.github.com/users/micklaw/gists{/gist_id}","starred_url":"https://api.github.com/users/micklaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micklaw/subscriptions","organizations_url":"https://api.github.com/users/micklaw/orgs","repos_url":"https://api.github.com/users/micklaw/repos","events_url":"https://api.github.com/users/micklaw/events{/privacy}","received_events_url":"https://api.github.com/users/micklaw/received_events","type":"User","site_admin":false},"body":"As we need to grab an instance of the the archetype model POCO(s) to populate, we can only get this via the archetype alias (string), this method checks the dlls classes in the application for types which inherit from the base Archetype Model and where the class name matches the alias. Thinking about it we may also need to check if the alias has been set via an attribute, but it could be easily extended for that. \n\nI have filtered out System.*, Microsoft.* and Windows.* dlls as I am pretty sure we would want to exclude them.\n\nThe results of this are cached and also in testing with a test install the execution time for sub 30ms, so seemed like a hit worth taking on first load of each type. \n\nCheers\n\nSent from my iPhone\n\n> On 8 Mar 2015, at 13:00, James South <notifications@github.com> wrote:\n> \n> In src/Our.Umbraco.Ditto/Extensions/TypeInferenceExtensions.cs:\n> \n> > @@ -90,5 +92,33 @@ public static IEnumerable<Type> GetBaseTypes(this Type type)\n> >                  type = type.BaseType;\n> >              }\n> >          }\n> > +\n> > +        /// <summary>\n> > +        /// Gets a all Type instances matching the specified class name with just non-namespace qualified class name.\n> > +        /// </summary>\n> > +        /// <param name=\"className\">Name of the class sought.</param>\n> > +        /// <param name=\"baseType\"></param>\n> > +        /// <returns>Types that have the class name specified. They may not be in the same namespace.</returns>\n> > +        public static IEnumerable<Type> GetTypeByName(string className, Type baseType)\n> > +        {\n> > +            /* [ML] - Look away kids, forgive me. We could improve performance with an optional app setting to filter assemblies \n> > +             * but this method executes in low milliseconds, hopefully with caching of these results we'll be ok\n> > +             */\n> > +\n> > +            var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(i => !i.FullName.ToLower().StartsWith(\"system\") && !i.FullName.ToLower().StartsWith(\"microsoft\") && !i.FullName.ToLower().StartsWith(\"windows\")).ToList();\n> What's this bit loading up?\n> \n> —\n> Reply to this email directly or view it on GitHub.\n> \n","created_at":"2015-03-08T13:10:35Z","updated_at":"2015-03-08T13:10:35Z","html_url":"https://github.com/leekelleher/umbraco-ditto/pull/44#discussion_r26004979","pull_request_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44","_links":{"self":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/comments/26004979"},"html":{"href":"https://github.com/leekelleher/umbraco-ditto/pull/44#discussion_r26004979"},"pull_request":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44"}}},"pull_request":{"url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44","id":30717589,"html_url":"https://github.com/leekelleher/umbraco-ditto/pull/44","diff_url":"https://github.com/leekelleher/umbraco-ditto/pull/44.diff","patch_url":"https://github.com/leekelleher/umbraco-ditto/pull/44.patch","issue_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/44","number":44,"state":"open","locked":false,"title":"Adding archetype support to Ditto","user":{"login":"micklaw","id":5840134,"avatar_url":"https://avatars.githubusercontent.com/u/5840134?v=3","gravatar_id":"","url":"https://api.github.com/users/micklaw","html_url":"https://github.com/micklaw","followers_url":"https://api.github.com/users/micklaw/followers","following_url":"https://api.github.com/users/micklaw/following{/other_user}","gists_url":"https://api.github.com/users/micklaw/gists{/gist_id}","starred_url":"https://api.github.com/users/micklaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micklaw/subscriptions","organizations_url":"https://api.github.com/users/micklaw/orgs","repos_url":"https://api.github.com/users/micklaw/repos","events_url":"https://api.github.com/users/micklaw/events{/privacy}","received_events_url":"https://api.github.com/users/micklaw/received_events","type":"User","site_admin":false},"body":"Adds support for archetype via the existing UmbracoPropertyAttributeClass which now contains an isArchetype field.\r\n\r\nThis hooks in to the existing TypeConverters and flow of application. Archetypes POCOs should follow the same naming convention standards as the main ditto POCOs, though will inherit from a base class of ArchetypeModel instead of the IPublishedContent.\r\n\r\nI have ran this against almost all of the existing data types and conversion seems OK, though as archetype values are strings one or two data types may have slipped through.","created_at":"2015-03-08T10:21:45Z","updated_at":"2015-03-08T13:10:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2031315afa7f2a18d15c566d716ec170386806c7","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":null,"commits_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44/commits","review_comments_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44/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/44/comments","statuses_url":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/616a71f5638bc6a385d4b24d6866c1843957b793","head":{"label":"micklaw:archetype","ref":"archetype","sha":"616a71f5638bc6a385d4b24d6866c1843957b793","user":{"login":"micklaw","id":5840134,"avatar_url":"https://avatars.githubusercontent.com/u/5840134?v=3","gravatar_id":"","url":"https://api.github.com/users/micklaw","html_url":"https://github.com/micklaw","followers_url":"https://api.github.com/users/micklaw/followers","following_url":"https://api.github.com/users/micklaw/following{/other_user}","gists_url":"https://api.github.com/users/micklaw/gists{/gist_id}","starred_url":"https://api.github.com/users/micklaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micklaw/subscriptions","organizations_url":"https://api.github.com/users/micklaw/orgs","repos_url":"https://api.github.com/users/micklaw/repos","events_url":"https://api.github.com/users/micklaw/events{/privacy}","received_events_url":"https://api.github.com/users/micklaw/received_events","type":"User","site_admin":false},"repo":{"id":31842732,"name":"umbraco-ditto","full_name":"micklaw/umbraco-ditto","owner":{"login":"micklaw","id":5840134,"avatar_url":"https://avatars.githubusercontent.com/u/5840134?v=3","gravatar_id":"","url":"https://api.github.com/users/micklaw","html_url":"https://github.com/micklaw","followers_url":"https://api.github.com/users/micklaw/followers","following_url":"https://api.github.com/users/micklaw/following{/other_user}","gists_url":"https://api.github.com/users/micklaw/gists{/gist_id}","starred_url":"https://api.github.com/users/micklaw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/micklaw/subscriptions","organizations_url":"https://api.github.com/users/micklaw/orgs","repos_url":"https://api.github.com/users/micklaw/repos","events_url":"https://api.github.com/users/micklaw/events{/privacy}","received_events_url":"https://api.github.com/users/micklaw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/micklaw/umbraco-ditto","description":"Ditto - the friendly POCO mapper for Umbraco 7+","fork":true,"url":"https://api.github.com/repos/micklaw/umbraco-ditto","forks_url":"https://api.github.com/repos/micklaw/umbraco-ditto/forks","keys_url":"https://api.github.com/repos/micklaw/umbraco-ditto/keys{/key_id}","collaborators_url":"https://api.github.com/repos/micklaw/umbraco-ditto/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/micklaw/umbraco-ditto/teams","hooks_url":"https://api.github.com/repos/micklaw/umbraco-ditto/hooks","issue_events_url":"https://api.github.com/repos/micklaw/umbraco-ditto/issues/events{/number}","events_url":"https://api.github.com/repos/micklaw/umbraco-ditto/events","assignees_url":"https://api.github.com/repos/micklaw/umbraco-ditto/assignees{/user}","branches_url":"https://api.github.com/repos/micklaw/umbraco-ditto/branches{/branch}","tags_url":"https://api.github.com/repos/micklaw/umbraco-ditto/tags","blobs_url":"https://api.github.com/repos/micklaw/umbraco-ditto/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/micklaw/umbraco-ditto/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/micklaw/umbraco-ditto/git/refs{/sha}","trees_url":"https://api.github.com/repos/micklaw/umbraco-ditto/git/trees{/sha}","statuses_url":"https://api.github.com/repos/micklaw/umbraco-ditto/statuses/{sha}","languages_url":"https://api.github.com/repos/micklaw/umbraco-ditto/languages","stargazers_url":"https://api.github.com/repos/micklaw/umbraco-ditto/stargazers","contributors_url":"https://api.github.com/repos/micklaw/umbraco-ditto/contributors","subscribers_url":"https://api.github.com/repos/micklaw/umbraco-ditto/subscribers","subscription_url":"https://api.github.com/repos/micklaw/umbraco-ditto/subscription","commits_url":"https://api.github.com/repos/micklaw/umbraco-ditto/commits{/sha}","git_commits_url":"https://api.github.com/repos/micklaw/umbraco-ditto/git/commits{/sha}","comments_url":"https://api.github.com/repos/micklaw/umbraco-ditto/comments{/number}","issue_comment_url":"https://api.github.com/repos/micklaw/umbraco-ditto/issues/comments{/number}","contents_url":"https://api.github.com/repos/micklaw/umbraco-ditto/contents/{+path}","compare_url":"https://api.github.com/repos/micklaw/umbraco-ditto/compare/{base}...{head}","merges_url":"https://api.github.com/repos/micklaw/umbraco-ditto/merges","archive_url":"https://api.github.com/repos/micklaw/umbraco-ditto/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/micklaw/umbraco-ditto/downloads","issues_url":"https://api.github.com/repos/micklaw/umbraco-ditto/issues{/number}","pulls_url":"https://api.github.com/repos/micklaw/umbraco-ditto/pulls{/number}","milestones_url":"https://api.github.com/repos/micklaw/umbraco-ditto/milestones{/number}","notifications_url":"https://api.github.com/repos/micklaw/umbraco-ditto/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/micklaw/umbraco-ditto/labels{/name}","releases_url":"https://api.github.com/repos/micklaw/umbraco-ditto/releases{/id}","created_at":"2015-03-08T08:03:21Z","updated_at":"2015-03-08T08:03:21Z","pushed_at":"2015-03-08T10:12:47Z","git_url":"git://github.com/micklaw/umbraco-ditto.git","ssh_url":"git@github.com:micklaw/umbraco-ditto.git","clone_url":"https://github.com/micklaw/umbraco-ditto.git","svn_url":"https://github.com/micklaw/umbraco-ditto","homepage":"http://our.umbraco.org/projects/developer-tools/ditto","size":5847,"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":"develop"}},"base":{"label":"leekelleher:develop","ref":"develop","sha":"d6eecc5b3ae85a437be511d00d25179d88a96868","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 7+","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-03-06T14:30:17Z","pushed_at":"2015-03-06T14:30:17Z","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":5847,"stargazers_count":31,"watchers_count":31,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":5,"forks":9,"open_issues":5,"watchers":31,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44"},"html":{"href":"https://github.com/leekelleher/umbraco-ditto/pull/44"},"issue":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/44"},"comments":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/issues/44/comments"},"review_comments":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/pulls/44/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/44/commits"},"statuses":{"href":"https://api.github.com/repos/leekelleher/umbraco-ditto/statuses/616a71f5638bc6a385d4b24d6866c1843957b793"}}}}