Skip to main content

Posts

Showing posts from September, 2015

A DD4T.net Implementation - Resolving Partial Models

In the previous post The Model Factory , I mentioned a couple of methods on the ModelFactory class that can be used to resolve partial models. But first, what are partial models? The way DD4T publishes linked Components depends on a parameter  LinkLevels  on the TBB  Generate dynamic component . This parameter indicates the number of levels to follow Component Links and to generate additional models for them. Its default value 1 means that only one level of Component Links will be followed starting with the current Component that is being published and this linked Component will only be published as a collection of metadata, while the Fields and MetadataFields collections are empty. These are partial models, because they contain only some information about the Component. When to use higher values for  LinkLevels and when not? If we increase the LinkLevels, the original Component model will contain models for all linked Components. This is very convenient whe...

A DD4T.net Implementation - The Model Factory

Now that we have Strongly Typed Models , Umbrella Models , Model Builders , Umbrella Model Builders and even a Model Generator Tool , we are still missing a little bit of functionality -- the model factory. The ModelFactory class should simply take the TcmUri of a Component and give us the model for it. The models should be cached, in order to gain performance, and the cache should listen to publish flush notification (but more about caching in a subsequent post). In this post, I'll focus of the ModelFactory class and its methods. I started by defining an interface IModelFactory that I can then hookup in Ninject as singleton, pointing to the only instance of its implementing class -- ModelFactory.     public interface IModelFactory     {         T GetModel<T>( string componentUri, string viewOrTemplateUri) where T : ModelBase ;         T GetModel<T>( IComp...