internal static IPublishedContentExtended Extend(IPublishedContent content, IEnumerable <IPublishedContent> contentSet) { var wrapped = content as PublishedContentExtended; while (wrapped != null && ((IPublishedContentExtended)wrapped).HasAddedProperties == false) { wrapped = (content = wrapped.Unwrap()) as PublishedContentExtended; } // if the factory returns something else than content it means it has created // a model, and then that model has to inherit from PublishedContentExtended, // => implements the internal IPublishedContentExtended. var model = PublishedContentModelFactory.CreateModel(content); var extended = model == content // == means the factory did not create a model ? new PublishedContentExtended(content) // so we have to extend : model; // else we can use what the factory returned var extended2 = extended as IPublishedContentExtended; if (extended2 != null) // always true, but keeps Resharper happy { extended2.SetContentSet(contentSet); } return(extended2); }
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { if (ConfigurationManager.AppSettings["UCreatePublishedModelsEnabled"] == null || !Convert.ToBoolean(ConfigurationManager.AppSettings["UCreatePublishedModelsEnabled"])) return; //Add published content factory var types = PluginManager.Current.ResolveTypes<PublishedContentModel>(); var factory = new PublishedContentModelFactory(types); PublishedContentModelFactoryResolver.Current.SetFactory(factory); }
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { // install standard factory if // - we want it // - we don't also want pure live models if (!Config.EnableFactory || Config.EnablePureLiveModels) return; var types = PluginManager.Current.ResolveTypes<PublishedContentModel>(); var factory = new PublishedContentModelFactory(types); PublishedContentModelFactoryResolver.Current.SetFactory(factory); }
protected override void ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) { IEnumerable<Type> types = PluginManager.Current.ResolveTypes<PublishedContentModel>(); var factory = new PublishedContentModelFactory(types); PublishedContentModelFactoryResolver.Current.SetFactory(factory); }