using System.Collections.Generic; using System.Configuration; using System.Linq; using Umbraco.Core; using Umbraco.Core.Composing; using Umbraco.Web.PublishedCache.NuCache.DataSource; namespace Umbraco.Web.PublishedCache.NuCache { public class NuCacheComposer : ComponentComposer, ICoreComposer { public override void Compose(Composition composition) { base.Compose(composition); var serializer = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.Serializer"]; composition.Register(); composition.Register(); if (serializer == "MsgPack") { var propertyDictionarySerializer = ConfigurationManager.AppSettings["Umbraco.Web.PublishedCache.NuCache.DictionaryOfPropertiesSerializer"]; if (propertyDictionarySerializer == "LZ4Map") { composition.Register(factory => { var lz4Serializer = factory.GetInstance(); return new ContentDataSerializer(lz4Serializer); }); } else { composition.Register(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer())); } composition.Register(); } else { composition.Register(); composition.Register(factory => new ContentDataSerializer(new DictionaryOfPropertyDataSerializer())); } // register the NuCache database data source composition.Register(); // register the NuCache published snapshot service // must register default options, required in the service ctor composition.Register(factory => new PublishedSnapshotServiceOptions()); composition.SetPublishedSnapshotService(); // add the NuCache health check (hidden from type finder) // TODO: no NuCache health check yet //composition.HealthChecks().Add(); } } }