public void Default_Processor_GlobalLevel_IsUsed()
        {
            Ditto.RegisterDefaultProcessorType <MyGlobalProcessorAttribute>();

            var model = Content.As <MyModel>();

            Assert.That(model.Name, Is.EqualTo("MyGlobalName"));

            // Tidy-up after test, otherwise the new default processor will cause other tests to fail!
            Ditto.RegisterDefaultProcessorType <UmbracoPropertyAttribute>();
        }
Beispiel #2
0
        public void Setup()
        {
            this.content = new MockPublishedContent
            {
                Id         = 1234,
                Name       = "MyCustomName",
                Properties = new[] { new MockPublishedContentProperty("item", "myValue") }
            };

            // Try running at a complete minimum, strip back everything
            Ditto.RegisterContextAccessor <NullContextAccessor>();
            Ditto.RegisterDefaultProcessorType <NullProcessorAttribute>();
            Ditto.DeregisterPostProcessorType <HtmlStringAttribute>();
            Ditto.DeregisterPostProcessorType <EnumerableConverterAttribute>();
            Ditto.DeregisterPostProcessorType <RecursiveDittoAttribute>();
            Ditto.DeregisterPostProcessorType <TryConvertToAttribute>();

            // pre-load the type config
            DittoTypeInfoCache.Add <BasicModel>();
        }
Beispiel #3
0
        /// <summary>
        /// Boot-up is completed, this allows you to perform any other boot-up logic required for the application.
        /// Resolution is frozen so now they can be used to resolve instances.
        /// </summary>
        /// <param name="umbracoApplication">
        /// The current <see cref="UmbracoApplicationBase"/>
        /// </param>
        /// <param name="applicationContext">
        /// The Umbraco <see cref="ApplicationContext"/> for the current application.
        /// </param>
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            // Try and install the package.
            if (!ZoombracoBootstrapper.Install(umbracoApplication, applicationContext))
            {
                return;
            }

            // Register custom routes.
            RouteBuilder.RegisterRoutes(RouteTable.Routes);

            // Ensure that the xml formatter does not interfere with API controllers.
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();

            // Clear out any CDN url requests on new image processing.
            // This ensures that when we update an image the cached CDN result for rendering is deleted.
            ImageProcessingModule.OnPostProcessing += (s, e) => { ZoombracoApplicationCache.RemoveItem(e.Context.Request.Unvalidated.RawUrl); };

            // Assign indexer for full text searching.
            UmbracoContentIndexer  indexProvider  = ExamineManager.Instance.IndexProviderCollection[ZoombracoConstants.Search.IndexerName] as UmbracoContentIndexer;
            UmbracoExamineSearcher searchProvider = ExamineManager.Instance.SearchProviderCollection[ZoombracoConstants.Search.SearcherName] as UmbracoExamineSearcher;

            if (indexProvider == null)
            {
                throw new ArgumentOutOfRangeException($"{ZoombracoConstants.Search.IndexerName} is missing. Please check the ExamineSettings.config file.");
            }

            if (searchProvider == null)
            {
                throw new ArgumentOutOfRangeException($"{ZoombracoConstants.Search.SearcherName} is missing. Please check the ExamineSettings.config file.");
            }

            UmbracoHelper helper        = new UmbracoHelper(UmbracoContext.Current);
            ContentHelper contentHelper = new ContentHelper(helper);

            indexProvider.GatheringNodeData += (sender, e) => this.GatheringNodeData(sender, e, helper, contentHelper, applicationContext);

            // Register the VortoPropertyAttribute as the default property processor so that any property can be made multilingual.
            Ditto.RegisterDefaultProcessorType <VortoPropertyAttribute>();
        }