Example #1
0
 private void InitMappers()
 {
     UmbMapperRegistry.AddMapper(new PublishedItemMap());
     UmbMapperRegistry.AddMapper(new LazyPublishedItemMap());
     UmbMapperRegistry.AddMapperFor <AutoMappedItem>();
     UmbMapperRegistry.AddMapper(new BackedPublishedItemMap());
     UmbMapperRegistry.AddMapper(new InheritedPublishedItemMap());
 }
        public void Setup()
        {
            this.support = new UmbracoSupport();
            this.content = this.support.Content;

            this.umbracoMapper = new UmbracoMapper();
            UmbMapperRegistry.AddMapperFor <TestClass>();
            UmbMapperRegistry.AddMapperFor <LazyTestClass>();
        }
Example #3
0
        /// <summary>
        /// All resolvers have been initialized but resolution is not frozen so they can be modified in this method
        /// </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 ApplicationStarting(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            UmbMapperRegistry.AddMapper(new PublishedImageMap());
            UmbMapperRegistry.AddMapper(new SlideMap());
            UmbMapperRegistry.AddMapper(new HomeMap());

            var factory = new UmbMapperPublishedContentModelFactory();

            PublishedContentModelFactoryResolver.Current.SetFactory(factory);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="UmbMapperPublishedContentModelFactory"/> class.
        /// </summary>
        public UmbMapperPublishedContentModelFactory()
        {
            IReadOnlyCollection <IUmbMapperConfig> mappers = UmbMapperRegistry.CurrentMappers();

            if (mappers.Count == 0)
            {
                throw new InvalidOperationException("No mappers have been registered. Ensure that registration occures before initialization of this factory.");
            }

            this.registeredMappers = mappers.Where(m => typeof(IPublishedContent).IsAssignableFrom(m.MappedType));
        }
Example #5
0
        private void TearDown()
        {
            if (PublishedCachesResolver.HasCurrent)
            {
                UmbracoContext.Current     = null;
                ApplicationContext.Current = null;
                UmbMapperRegistry.ClearMappers();
                PublishedCachesResolver.Reset();

                if (Resolution.IsFrozen)
                {
                    Resolution.Reset();
                }
            }
        }
Example #6
0
 public void UmbMapperRegistryCanStoreMapper()
 {
     UmbMapperRegistry.AddMapper(new PublishedItemMap());
     Assert.True(UmbMapperRegistry.CurrentMappers().Any(m => m.MappedType == typeof(PublishedItem)));
 }
 public void Cleanup()
 {
     this.support?.Dispose();
     UmbMapperRegistry.ClearMappers();
 }