Strongly typed doc-type classes in the integration bus

Hughie Coles asked on February 5, 2015 16:29

I've created strongly typed classes for a set of document types in my application. I'd like to be able to get strongly typed objects coming through in the ProcessInternalTaskAsync() method rather than TreeNode's. Is this possible?

Thanks,

Hughie Coles

Correct Answer

Nathan Eary answered on February 5, 2015 23:02

Actually, if your Document Type classes inherit from TreeNode, you can use CMSModuleLoader attributes to make the document factory load instances of your class when it loads treenodes with the specified class name. You can then cast the treenode as your custom type.Just stick this partial class code somewhere. I usually just put it right before my class definiton. Also, Kentico has a built in class generator that you can see under the Fields list in the Document Type editor if you have Development mode turned on. You can do this for CustomTables too. Image Text

    [DocumentType("TheKenticoDocumentTypeClassName", typeof(YourClassType))]
public partial class CMSModuleLoader
{
}
1 votesVote for this answer Unmark Correct answer

Recent Answers


Brenden Kehren answered on February 5, 2015 18:36

In your ProcessInternalTaskAsync() method, use the tree node object to get the object class and create an instance of your strongly typed object. The only other way you'd be able to do what you're looking for is by having the source code of Kentico to modify their process.

0 votesVote for this answer Mark as a Correct answer

Hughie Coles answered on February 5, 2015 19:59

I figured as much. Thanks for your input.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on February 6, 2015 01:30

Ahh yes, I forgot about that awesome feature in v8 Nathan! I'd go that route.

0 votesVote for this answer Mark as a Correct answer

Nathan Eary answered on February 6, 2015 07:01 (last edited on February 6, 2015 17:22)

It's actually a feature available in 7, maybe even 6. I first used it in 7, so I'm not sure. There's not a lot of documentation on it. I discovered it by accident.

Edit: It's not in 6. They added it in 7 when they moved the code from CMS.TreeEngine to CMS.DocumentEngine

0 votesVote for this answer Mark as a Correct answer

Hughie Coles answered on February 6, 2015 18:37

That's the perfect solution. It's also great to know that it applies to K7 as well.

Thank you Nathan.

0 votesVote for this answer Mark as a Correct answer

Nathan Eary answered on February 18, 2015 15:52 (last edited on February 18, 2015 20:13)

It looks like the Generate Code File link was removed in 8.1. I don't see it in the control for the fields at all anymore. They moved it to a "Code" tab in the left-hand menu of the document type details. This is actually an improvement.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.