示例#1
0
 public static IServiceCollection AddUmbracoHeadlessContentDelivery(this IServiceCollection services,
                                                                    UmbracoConfig umbracoConfig)
 {
     services.TryAddSingleton(string.IsNullOrEmpty(umbracoConfig.ApiKey)
         ? new ContentDeliveryService(umbracoConfig.ProjectAlias)
         : new ContentDeliveryService(umbracoConfig.ProjectAlias, umbracoConfig.ApiKey));
     return(services);
 }
示例#2
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();

            var umbracoConfig = new UmbracoConfig();

            Configuration.GetSection(nameof(UmbracoConfig)).Bind(umbracoConfig);

            services.AddStazorPagesHeartcore(_webHostEnvironment, umbracoConfig, new TypeResolver());
        }
示例#3
0
        public static ArticulateOptions ArticulateOptions(this UmbracoConfig umbracoConfig)
        {
            LazyInitializer.EnsureInitialized(ref _options, () => Options.ArticulateOptions.Default);

            return(_options);
        }
 /// <summary>
 /// Gets configuration for personalisation groups.
 /// </summary>
 /// <param name="umbracoConfig">The umbraco configuration.</param>
 /// <returns>The personalisation groups configuration.</returns>
 /// <remarks>
 /// Getting the personalisation groups configuration freezes its state, and
 /// any attempt at modifying the configuration will be ignored.
 /// </remarks>
 public static PersonalisationGroupsConfig PersonalisationGroups(this UmbracoConfig umbracoConfig)
 {
     LazyInitializer.EnsureInitialized(ref _config, () => PersonalisationGroupsConfig.Value);
     return(_config);
 }
示例#5
0
 /// <summary>
 /// Gets configuration for Phone Manager.
 /// </summary>
 /// <param name="umbracoConfig">The umbraco configuration.</param>
 /// <returns>The Phone Manager configuration.</returns>
 /// <remarks>
 /// Getting the personalisation groups configuration freezes its state, and
 /// any attempt at modifying the configuration will be ignored.
 /// </remarks>
 public static AppSettingsConfig PhoneManager(this UmbracoConfig umbracoConfig)
 {
     LazyInitializer.EnsureInitialized(ref _config, () => AppSettingsConfig.Value);
     return(_config);
 }
 /// <summary>
 /// Gets the models builder configuration.
 /// </summary>
 /// <param name="umbracoConfig">The umbraco configuration.</param>
 /// <returns>The models builder configuration.</returns>
 /// <remarks>Getting the models builder configuration freezes its state,
 /// and any attempt at modifying the configuration using the Setup method
 /// will be ignored.</remarks>
 public static Config ModelsBuilder(this UmbracoConfig umbracoConfig)
 {
     // capture the current Config2.Default value, cannot change anymore
     LazyInitializer.EnsureInitialized(ref _config, () => Config.Value);
     return(_config);
 }
示例#7
0
        public static IServiceCollection AddStazorPagesHeartcore(this IServiceCollection services, IWebHostEnvironment env, UmbracoConfig config, ITypeResolver typeResolver)
        {
            services.AddUmbracoHeadlessContentDelivery(config);

            services.AddSingleton <ITypeResolver>(typeResolver);
            services.AddSingleton <IContentService, HeartcoreContentService>();
            services.AddSingleton <HeartcoreCache>();

            services.AddStazorPages(env);

            return(services);
        }