{"action":"created","issue":{"url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/51","labels_url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/51/labels{/name}","comments_url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/51/comments","events_url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/51/events","html_url":"https://github.com/zpqrtbnk/Zbu.ModelsBuilder/issues/51","id":82165761,"number":51,"title":"Utilizing custom code for DocType Compositions?","user":{"login":"hfloyd","id":1252593,"avatar_url":"https://avatars.githubusercontent.com/u/1252593?v=3","gravatar_id":"","url":"https://api.github.com/users/hfloyd","html_url":"https://github.com/hfloyd","followers_url":"https://api.github.com/users/hfloyd/followers","following_url":"https://api.github.com/users/hfloyd/following{/other_user}","gists_url":"https://api.github.com/users/hfloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/hfloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hfloyd/subscriptions","organizations_url":"https://api.github.com/users/hfloyd/orgs","repos_url":"https://api.github.com/users/hfloyd/repos","events_url":"https://api.github.com/users/hfloyd/events{/privacy}","received_events_url":"https://api.github.com/users/hfloyd/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":{"login":"zpqrtbnk","id":2846429,"avatar_url":"https://avatars.githubusercontent.com/u/2846429?v=3","gravatar_id":"","url":"https://api.github.com/users/zpqrtbnk","html_url":"https://github.com/zpqrtbnk","followers_url":"https://api.github.com/users/zpqrtbnk/followers","following_url":"https://api.github.com/users/zpqrtbnk/following{/other_user}","gists_url":"https://api.github.com/users/zpqrtbnk/gists{/gist_id}","starred_url":"https://api.github.com/users/zpqrtbnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zpqrtbnk/subscriptions","organizations_url":"https://api.github.com/users/zpqrtbnk/orgs","repos_url":"https://api.github.com/users/zpqrtbnk/repos","events_url":"https://api.github.com/users/zpqrtbnk/events{/privacy}","received_events_url":"https://api.github.com/users/zpqrtbnk/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/milestones/8","html_url":"https://github.com/zpqrtbnk/Zbu.ModelsBuilder/milestones/2.1.3","labels_url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/milestones/8/labels","id":1118292,"number":8,"title":"2.1.3","description":"Bugfixes","creator":{"login":"zpqrtbnk","id":2846429,"avatar_url":"https://avatars.githubusercontent.com/u/2846429?v=3","gravatar_id":"","url":"https://api.github.com/users/zpqrtbnk","html_url":"https://github.com/zpqrtbnk","followers_url":"https://api.github.com/users/zpqrtbnk/followers","following_url":"https://api.github.com/users/zpqrtbnk/following{/other_user}","gists_url":"https://api.github.com/users/zpqrtbnk/gists{/gist_id}","starred_url":"https://api.github.com/users/zpqrtbnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zpqrtbnk/subscriptions","organizations_url":"https://api.github.com/users/zpqrtbnk/orgs","repos_url":"https://api.github.com/users/zpqrtbnk/repos","events_url":"https://api.github.com/users/zpqrtbnk/events{/privacy}","received_events_url":"https://api.github.com/users/zpqrtbnk/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":6,"state":"closed","created_at":"2015-05-19T14:08:24Z","updated_at":"2015-09-16T12:11:17Z","due_on":"2015-07-20T22:00:00Z","closed_at":"2015-09-16T12:11:17Z"},"comments":19,"created_at":"2015-05-28T23:17:44Z","updated_at":"2015-11-02T15:54:00Z","closed_at":"2015-07-14T12:00:05Z","body":"A question about your thoughts for properly utilizing the generated code for Doctype \"Compositions/mixins\".\r\n\r\n**Basic Master/Child DocTypes Relationship**\r\n\r\nIf we have a simple Master > Child doctype relationship, ModelsBuilder creates a class for each, and the child inherits the master - this makes sense. \r\n\r\n\tpublic partial class MasterDocument : PublishedContentModel {...}\r\n\t\r\n\tpublic partial class ChildDocument : MasterDocument {...}\r\n\r\nAnd, if we implement custom property handling in the customized partial for the \"master\" class, those enhancements are immediately and automatically available to the child doctype class. If we change the implementation of those customized properties, we just change them in that one place - the master class.\r\n\r\n**Compositions in DocTypes**\r\n\r\nWhen using the \"Compositions\" (AKA \"Mix-ins\"), ModelsBuilder generates an interface representing the Composition as well as a class implementing that interface:\r\n\r\n\tpublic partial interface IMyComposition : IPublishedContent {...}\r\n\r\n\tpublic partial class MyComposition : PublishedContentModel, IMyComposition {...}\r\n\r\n\t\r\nSince \"Compositions\" are only top-level doctypes (meaning, not a child of another doctype), and thus could also be used as a doctype in their own right on a Content node, they do need their own class in the model.\r\n\r\nWhen the classes are generated for a Doctype which uses a composition, the class implements the interface of the composition:\r\n\r\n\tpublic partial class ChildDocument : MasterDocument, IMyComposition {...}\r\n\r\n**My question is: How should customized properties for a Composition be accessed by those Doctypes which implement the composition interface?**\r\n\r\nMy initial thought was that the custom properties would be defined in the Composition class, then \"called\" from the custom code partials for any implementing Doctypes.\r\n\r\nExample of custom property on MyComposition:\r\n\r\n\tpublic partial interface IMyComposition\r\n    {\r\n        IEnumerable<IPublishedContent> SelectedNodes { get; }\r\n    }\r\n\r\n\tpublic partial class MyComposition\r\n    {\r\n\t\tpublic IEnumerable<IPublishedContent> SelectedNodes\r\n        {\r\n            get\r\n            {\r\n\t\t\t\t//assuming that there is a MNTP property on the MyComposition doctype named \"mntpSelected\"...\r\n\t\t\t\tvar selectedNodes = ...code to get an IEnum of the nodes from the property \"mntpSelected\"... ;\r\n                return selectedNodes;\r\n            }\r\n        }\r\n\r\nExample of implementing:\r\n\r\n\tpublic partial class ChildDocument\r\n    {\r\n        public IEnumerable<IPublishedContent> SelectedNodes\r\n        {\r\n            get\r\n            {\r\n                var myComp = new MyComposition(this);\r\n                return myComp.SelectedNodes;\r\n            }\r\n        }\r\n\t}\r\n\r\nBut in practice, when calling the property, even if the underlying MNTP data exists, the custom property returns NULL.\r\n\r\n\t@inherits UmbracoViewPage<BaseModel<ChildDocument>>\r\n\t\r\n\t@Model.Content.mntpSelected <-- This has the CSV of node IDs as expected...\r\n\t@Model.Content.SelectedNodes <-- This is always Null\r\n\r\nI had assumed that the current actual IPublishedContent would be used to evaluate the custom properties, but that doesn't seem to be the case. \r\n\r\n**Can you suggest a strategy to utilize custom properties related to a Composition?** Ideally, there would only be one location for the logic to be defined, in the interests of future maintainability.\r\n"},"comment":{"url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/comments/153060335","html_url":"https://github.com/zpqrtbnk/Zbu.ModelsBuilder/issues/51#issuecomment-153060335","issue_url":"https://api.github.com/repos/zpqrtbnk/Zbu.ModelsBuilder/issues/51","id":153060335,"user":{"login":"zpqrtbnk","id":2846429,"avatar_url":"https://avatars.githubusercontent.com/u/2846429?v=3","gravatar_id":"","url":"https://api.github.com/users/zpqrtbnk","html_url":"https://github.com/zpqrtbnk","followers_url":"https://api.github.com/users/zpqrtbnk/followers","following_url":"https://api.github.com/users/zpqrtbnk/following{/other_user}","gists_url":"https://api.github.com/users/zpqrtbnk/gists{/gist_id}","starred_url":"https://api.github.com/users/zpqrtbnk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zpqrtbnk/subscriptions","organizations_url":"https://api.github.com/users/zpqrtbnk/orgs","repos_url":"https://api.github.com/users/zpqrtbnk/repos","events_url":"https://api.github.com/users/zpqrtbnk/events{/privacy}","received_events_url":"https://api.github.com/users/zpqrtbnk/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T15:54:00Z","updated_at":"2015-11-02T15:54:00Z","body":"Not sure I understand what you are trying to do here. Why would you need to define the \"meta\" properties explicitely in your CompPageSettings.cs file? Aren't they normal, existing Umbraco properties--and then on what document type are they defined?"}}