public static CloudyConfigurator AddAdmin(this CloudyConfigurator configurator)
        {
            configurator.AddComponent <CloudyAdminComponent>();
            configurator.Services.AddSingleton(new CloudyAdminOptions());

            return(configurator);
        }
        public static void AddCloudy(this IServiceCollection services, Action <CloudyConfigurator> cloudy)
        {
            services.Configure <RouteOptions>(options =>
            {
                options.ConstraintMap.Add("contentroute", typeof(ContentRouteConstraint));
            });

            var options      = new CloudyOptions();
            var configurator = new CloudyConfigurator(services, options);

            cloudy(configurator);

            configurator.AddComponent <CloudyAssemblyHandle>();

            if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly())
            {
                configurator.AddComponentAssembly(Assembly.GetCallingAssembly());
            }

            var AssemblyProvider = new AssemblyProvider(options.Assemblies.Select(a => new AssemblyWrapper(a)));

            services.AddSingleton <IAssemblyProvider>(AssemblyProvider);


            services.AddSingleton <IContextDescriptorProvider>(new ContextDescriptorProvider(ContextDescriptor.CreateFrom(options.Contexts)));

            foreach (var injector in new DependencyInjectorProvider(new DependencyInjectorCreator(AssemblyProvider)).GetAll())
            {
                injector.InjectDependencies(services);
            }

            services.AddTransient <IStartupFilter, InitializerBootstrapper>();
        }
 public static CloudyConfigurator AddFileBasedDocuments(this CloudyConfigurator cloudy, string path = "json")
 {
     cloudy.AddCachedDocuments <FileDataSource>();
     cloudy.Services.AddSingleton <IFileHandler, FileHandler>();
     cloudy.Services.AddSingleton <IFilePathProvider, FilePathProvider>();
     cloudy.Services.AddSingleton <IFileBasedDocumentOptions>(new FileBasedDocumentOptions(path));
     return(cloudy);
 }
Example #4
0
        public static CloudyConfigurator WithKubernetesCrds(this CloudyConfigurator configurator)
        {
            configurator.Options.HasDocumentProvider = true;

            configurator.AddComponent <KubernetesCrdComponent>();

            return(configurator);
        }
Example #5
0
 public static CloudyConfigurator AddInMemory(this CloudyConfigurator instance)
 {
     instance.Services.AddSingleton <IDocumentGetter, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentCreator, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentUpdater, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentDeleter, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentFinder, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentFinder, DocumentRepository>();
     instance.Services.AddSingleton <IDocumentFinderQueryBuilder, DocumentFinderQueryBuilder>();
     instance.Services.AddSingleton <IDocumentPropertyFinder, DocumentPropertyFinder>();
     return(instance);
 }
        public static CloudyConfigurator WithMongoDatabaseConnectionStringNamed(this CloudyConfigurator configurator, string name)
        {
            if (name.Contains(":") || name.Contains("/"))
            {
                throw new ArgumentException("Connection strings have to be referenced by name from your appsettings.json. No direct URLs here. You'll thank me later!");
            }

            configurator.AddMongo();
            configurator.Options.HasDocumentProvider = true;
            configurator.Services.AddSingleton <IDatabaseConnectionStringNameProvider>(new DatabaseConnectionStringNameProvider(name));

            return(configurator);
        }
Example #7
0
        public static CloudyConfigurator AddMongo(this CloudyConfigurator configurator)
        {
            configurator.Services.AddSingleton <IContainerProvider, ContainerProvider>();
            configurator.Services.AddSingleton <IDatabaseProvider, DatabaseProvider>();
            configurator.Services.AddSingleton <IDatabaseConnectionStringNameProvider, NoDatabaseConnectionStringNameProvider>();
            configurator.Services.AddSingleton <IDocumentCreator, DocumentCreator>();
            configurator.Services.AddSingleton <IDocumentDeleter, DocumentDeleter>();
            configurator.Services.AddSingleton <IDocumentFinder, DocumentFinder>();
            configurator.Services.AddSingleton <IDocumentGetter, DocumentGetter>();
            configurator.Services.AddSingleton <IDocumentUpdater, DocumentUpdater>();
            configurator.Services.AddTransient <IDocumentFinderQueryBuilder, DocumentFinderQueryBuilder>();

            return(configurator);
        }
        public static CloudyConfigurator WithJsonBoxDocuments(this CloudyConfigurator configurator, string endpoint)
        {
            configurator.Services.AddSingleton <IEndpointProvider>(new EndpointProvider(endpoint));
            configurator.Services.AddTransient <IDocumentPropertyFinder, DocumentPropertyFinder>();
            configurator.Services.AddSingleton <IDocumentCreator, DocumentCreator>();
            configurator.Services.AddSingleton <IDocumentDeleter, DocumentDeleter>();
            configurator.Services.AddSingleton <IDocumentFinder, DocumentFinder>();
            configurator.Services.AddSingleton <IDocumentGetter, DocumentGetter>();
            configurator.Services.AddSingleton <IDocumentUpdater, DocumentUpdater>();
            configurator.Services.AddTransient <IDocumentFinderQueryBuilder, DocumentFinderQueryBuilder>();

            configurator.Options.HasDocumentProvider = true;

            return(configurator);
        }
        /// <summary>
        /// Adds document repository support with a 2nd level inmemory cache using the specified data source. All documents will be fetched on startup.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="cloudy"></param>
        /// <returns></returns>
        public static CloudyConfigurator AddCachedDocuments <T>(this CloudyConfigurator cloudy) where T : class, IDataSource
        {
            cloudy.Services.AddSingleton <IDocumentGetter, CachedDocumentRepository>();
            cloudy.Services.AddSingleton <IDocumentCreator, CachedDocumentRepository>();
            cloudy.Services.AddSingleton <IDocumentUpdater, CachedDocumentRepository>();
            cloudy.Services.AddSingleton <IDocumentDeleter, CachedDocumentRepository>();
            cloudy.Services.AddSingleton <IDocumentFinder, CachedDocumentRepository>();
            cloudy.Services.AddSingleton <IDocumentLister, CachedDocumentRepository>();
            cloudy.Services.AddTransient <IDocumentFinderQueryBuilder, DocumentFinderQueryBuilder>();
            cloudy.Services.AddSingleton <IDocumentPropertyPathProvider, DocumentPropertyPathProvider>();
            cloudy.Services.AddSingleton <IDocumentPropertyFinder, DocumentPropertyFinder>();
            cloudy.Services.AddSingleton <IDataSource, T>();

            return(cloudy);
        }
Example #10
0
        public static CloudyConfigurator AddFileBased(this CloudyConfigurator configurator, string path = "json")
        {
            configurator.Services.AddSingleton <IFileBasedDocumentOptions>(new FileBasedDocumentOptions(path));
            configurator.Services.AddSingleton <IFilePathProvider, FilePathProvider>();
            configurator.Services.AddSingleton <IFileHandler, FileHandler>();
            configurator.Services.AddSingleton <IDocumentSerializer, DocumentSerializer>();
            configurator.Services.AddSingleton <IDocumentDeserializer, DocumentDeserializer>();
            configurator.Services.AddTransient <IDocumentPropertyFinder, DocumentPropertyFinder>();
            configurator.Services.AddSingleton <IDocumentCreator, DocumentCreator>();
            configurator.Services.AddSingleton <IDocumentDeleter, DocumentDeleter>();
            configurator.Services.AddSingleton <IDocumentFinder, DocumentFinder>();
            configurator.Services.AddSingleton <IDocumentGetter, DocumentGetter>();
            configurator.Services.AddSingleton <IDocumentUpdater, DocumentUpdater>();
            configurator.Services.AddTransient <IDocumentFinderQueryBuilder, DocumentFinderQueryBuilder>();

            return(configurator);
        }
Example #11
0
        public static CloudyConfigurator AddAdmin(this CloudyConfigurator configurator, Action <CloudyAdminConfigurator> admin)
        {
            configurator.AddComponent <CloudyUIAssemblyHandle>();

            var options = new CloudyAdminOptions();

            admin(new CloudyAdminConfigurator(options));
            configurator.Services.AddSingleton(options);

            if (options.Unprotect)
            {
                configurator.Services.Configure <AuthorizationOptions>(o => o.AddPolicy("Cloudy.CMS.UI", builder => builder.RequireAssertion(a => true)));
            }
            else
            {
                configurator.Services.Configure <AuthorizationOptions>(o => o.AddPolicy("Cloudy.CMS.UI", builder => builder.RequireAuthenticatedUser()));
            }

            return(configurator);
        }
Example #12
0
        public static void AddCloudy(this IServiceCollection services, Action <CloudyConfigurator> configure)
        {
            services.Configure <RouteOptions>(options =>
            {
                options.ConstraintMap.Add("contentroute", typeof(ContentRouteConstraint));
            });

            var options      = new CloudyOptions();
            var configurator = new CloudyConfigurator(services, options);

            configure(configurator);

            configurator.AddComponent <CloudyComponent>();

            if (Assembly.GetCallingAssembly() != Assembly.GetExecutingAssembly())
            {
                configurator.AddComponentAssembly(Assembly.GetCallingAssembly());
            }

            if (!options.HasDocumentProvider)
            {
                configurator.WithInMemoryDatabase();
            }

            var componentAssemblyProvider = new ComponentAssemblyProvider(options.ComponentAssemblies);

            services.AddSingleton <IComponentAssemblyProvider>(componentAssemblyProvider);

            var componentTypeProvider = new ComponentTypeProvider(options.Components);

            services.AddSingleton <IComponentTypeProvider>(componentTypeProvider);

            new CloudyDependencyInjector().InjectDependencies(services);

            foreach (var injector in new DependencyInjectorProvider(new DependencyInjectorCreator(componentAssemblyProvider, componentTypeProvider)).GetAll())
            {
                injector.InjectDependencies(services);
            }

            services.AddTransient <IStartupFilter, InitializerBootstrapper>();
        }
 public static CloudyConfigurator AddInMemoryDocuments(this CloudyConfigurator cloudy)
 {
     cloudy.AddCachedDocuments <InMemoryDataSource>();
     return(cloudy);
 }
Example #14
0
 public static CloudyConfigurator AddAdmin(this CloudyConfigurator configurator)
 {
     return(configurator.AddAdmin(admin => { }));
 }