Example #1
0
        public static IUmbracoBuilder AddVendrReviews(this IUmbracoBuilder builder, Action <VendrReviewsSettings> defaultOptions = default)
        {
            // Register configuration
            var options = builder.Services.AddOptions <VendrReviewsSettings>()
                          .Bind(builder.Config.GetSection(Constants.System.ProductName));

            if (defaultOptions != default)
            {
                options.Configure(defaultOptions);
            }

            options.ValidateDataAnnotations();

            // Register services
            builder.Services.AddTransient <IReviewRepositoryFactory, ReviewRepositoryFactory>();
            builder.Services.AddSingleton <IReviewService, ReviewService>();
            builder.Services.AddSingleton <VendrReviewsApi>();

            // Register event handlers
#if NET
            builder.AddNotificationHandler <TreeNodesRenderingNotification, ReviewsTreeNodesNotification>();
#endif
            builder.AddVendrReviewsEventHandlers();

            // Register component
            builder.Components()
            .Append <VendrReviewsComponent>();

            return(builder);
        }