Ejemplo n.º 1
0
        public static GremlinqSetup UseCosmosDb(this GremlinqSetup setup, Action <ProviderSetup <ICosmosDbConfigurator> >?extraSetupAction = null)
        {
            return(setup
                   .UseProvider(
                       "CosmosDb",
                       (source, configuratorTransformation) => source
                       .UseCosmosDb(configuratorTransformation),
                       setup => setup
                       .ConfigureWebSocket()
                       .Configure((configurator, providerSection) =>
            {
                if (providerSection["Database"] is { } databaseName)
                {
                    configurator = configurator.OnDatabase(databaseName);
                }

                if (providerSection["Graph"] is { } graphName)
                {
                    configurator = configurator.OnGraph(graphName);
                }

                if (providerSection["AuthKey"] is { } authKey)
                {
                    configurator = configurator.AuthenticateBy(authKey);
                }

                return configurator;
            }),
                       extraSetupAction));
        }
Ejemplo n.º 2
0
        public static GremlinqSetup UseNeptune(this GremlinqSetup setup, Action <ProviderSetup <INeptuneConfigurator> >?extraSetupAction = null)
        {
            return(setup
                   .UseProvider(
                       "Neptune",
                       (source, configuratorTransformation) => source
                       .UseNeptune(configuratorTransformation),
                       setup => setup
                       .ConfigureWebSocket()
                       .Configure((configurator, providerSection) =>
            {
                if (providerSection.GetSection("ElasticSearch") is { } elasticSearchSection)
                {
                    if (bool.TryParse(elasticSearchSection["Enabled"], out var isEnabled) && isEnabled)
                    {
                        if (elasticSearchSection["EndPoint"] is { } endPoint&& Uri.TryCreate(endPoint, UriKind.Absolute, out var uri))
                        {
                            var indexConfiguration = Enum.TryParse <NeptuneElasticSearchIndexConfiguration>(elasticSearchSection["IndexConfiguration"], true, out var outVar)
                                            ? outVar
                                            : NeptuneElasticSearchIndexConfiguration.Standard;

                            configurator = configurator
                                           .UseElasticSearch(uri, indexConfiguration);
                        }
                    }
                }

                return configurator;
            }),
                       extraSetupAction));
        }
 public static GremlinqSetup UseGremlinServer <TVertex, TEdge>(this GremlinqSetup setup)
 {
     return(setup
            .UseGremlinServer()
            .UseModel(GraphModel
                      .FromBaseTypes <TVertex, TEdge>(lookup => lookup
                                                      .IncludeAssembliesOfBaseTypes())));
 }
Ejemplo n.º 4
0
 public static GremlinqSetup UseConfigurationSection(this GremlinqSetup setup, string sectionName)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton <IGremlinqConfiguration>(serviceProvider => new GremlinqConfiguration(serviceProvider
                                                                                                                    .GetServiceOrThrow <IConfiguration>()
                                                                                                                    .GetSection(sectionName)
                                                                                                                    .GetSection("Gremlinq")))));
 }
Ejemplo n.º 5
0
 public static GremlinqSetup UseJanusGraph <TVertex, TEdge>(this GremlinqSetup setup, Action <ProviderSetup <IJanusGraphConfigurator> >?extraSetupAction = null)
 {
     return(setup
            .UseJanusGraph(extraSetupAction)
            .ConfigureEnvironment(env => env
                                  .UseModel(GraphModel
                                            .FromBaseTypes <TVertex, TEdge>(lookup => lookup
                                                                            .IncludeAssembliesOfBaseTypes()))));
 }
Ejemplo n.º 6
0
 public static GremlinqSetup UseJanusGraph(this GremlinqSetup setup, Action <ProviderSetup <IJanusGraphConfigurator> >?extraSetupAction = null)
 {
     return(setup
            .UseProvider(
                "JanusGraph",
                (source, configuratorTransformation) => source
                .UseJanusGraph(configuratorTransformation),
                setup => setup
                .ConfigureWebSocket(),
                extraSetupAction));
 }
Ejemplo n.º 7
0
 public static GremlinqSetup UseCosmosDb <TVertex, TEdge>(this GremlinqSetup setup, Expression <Func <TVertex, object> > partitionKeyExpression)
 {
     return(setup
            .UseCosmosDb()
            .UseModel(GraphModel
                      .FromBaseTypes <TVertex, TEdge>(lookup => lookup
                                                      .IncludeAssembliesOfBaseTypes())
                      .ConfigureProperties(model => model
                                           .ConfigureElement <TVertex>(conf => conf
                                                                       .IgnoreOnUpdate(partitionKeyExpression)))));
 }
Ejemplo n.º 8
0
 public static GremlinqSetup UseCosmosDb <TVertex, TEdge>(this GremlinqSetup setup, Expression <Func <TVertex, object> > partitionKeyExpression, Action <ProviderSetup <ICosmosDbConfigurator> >?extraSetupAction = null)
 {
     return(setup
            .UseCosmosDb(extraSetupAction)
            .ConfigureEnvironment(env => env
                                  .UseModel(GraphModel
                                            .FromBaseTypes <TVertex, TEdge>(lookup => lookup
                                                                            .IncludeAssembliesOfBaseTypes())
                                            .ConfigureProperties(model => model
                                                                 .ConfigureElement <TVertex>(conf => conf
                                                                                             .IgnoreOnUpdate(partitionKeyExpression))))));
 }
        public static GremlinqSetup UseProvider <TConfigurator>(
            this GremlinqSetup setup,
            string sectionName,
            Func <IConfigurableGremlinQuerySource, Func <TConfigurator, IGremlinQuerySourceTransformation>, IGremlinQuerySource> providerChoice,
            Action <ProviderSetup <TConfigurator> > setupAction,
            Action <ProviderSetup <TConfigurator> >?extraSetupAction) where TConfigurator : IProviderConfigurator <TConfigurator>
        {
            setupAction(new ProviderSetup <TConfigurator>(setup.ServiceCollection));

            if (extraSetupAction is { } extraConfiguration)
            {
                extraConfiguration(new ProviderSetup <TConfigurator>(setup.ServiceCollection));
            }

            return(setup.RegisterTypes(serviceCollection => serviceCollection
                                       .AddSingleton(new ProviderSetupInfo <TConfigurator>(sectionName, providerChoice))
                                       .AddSingleton <IGremlinQuerySourceTransformation, UseProviderGremlinQuerySourceTransformation <TConfigurator> >()
                                       .AddSingleton <IProviderConfigurationSection, ProviderConfigurationSection <TConfigurator> >()));
        }
Ejemplo n.º 10
0
        public static GremlinqSetup RegisterTypes(this GremlinqSetup setup, Action <IServiceCollection> registration)
        {
            registration(setup.ServiceCollection);

            return(setup);
        }
Ejemplo n.º 11
0
 public static GremlinqSetup ConfigureEnvironment(this GremlinqSetup setup, Func <IGremlinQueryEnvironment, IGremlinQueryEnvironment> environmentTransformation)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton <IGremlinQueryEnvironmentTransformation>(new EnvironmentTransformation(environmentTransformation))));
 }
Ejemplo n.º 12
0
 public static GremlinqSetup UseConfigurationSection(this GremlinqSetup setup, string sectionName)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton(new GremlinqSetupInfo(sectionName))));
 }
Ejemplo n.º 13
0
 public static GremlinqSetup UseModel(this GremlinqSetup setup, IGraphModel model)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton(model)
                                .AddSingleton <IGremlinQueryEnvironmentTransformation, UseModelTransformation>()));
 }
 public static GremlinqSetup ConfigureWebSocketBuilder(this GremlinqSetup setup, Func <IWebSocketGremlinQueryExecutorBuilder, IWebSocketGremlinQueryExecutorBuilder> transformation)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton <IWebSocketGremlinQueryExecutorBuilderTransformation>(_ => new ConfigureWebSocketGremlinQueryExecutorBuilderTransformation(transformation))));
 }
 public static GremlinqSetup UseWebSocket(this GremlinqSetup setup)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton <IGremlinQueryEnvironmentTransformation, ConfigureLoggingGremlinQueryEnvironmentTransformation>()));
 }
Ejemplo n.º 16
0
 public static GremlinqSetup UseNeptune(this GremlinqSetup setup)
 {
     return(setup
            .UseWebSocket()
            .RegisterTypes(serviceCollection => serviceCollection.AddSingleton <IGremlinQueryEnvironmentTransformation, UseNeptuneGremlinQueryEnvironmentTransformation>()));
 }
Ejemplo n.º 17
0
 public static GremlinqSetup ConfigureQuerySource(this GremlinqSetup setup, Func <IGremlinQuerySource, IGremlinQuerySource> sourceTranformation)
 {
     return(setup.RegisterTypes(serviceCollection => serviceCollection
                                .AddSingleton <IGremlinQuerySourceTransformation>(new SourceTransformation(sourceTranformation))));
 }
 public static GremlinqSetup UseJanusGraph(this GremlinqSetup setup)
 {
     return(new GremlinqSetup(setup.ServiceCollection.AddSingleton <IGremlinQueryEnvironmentTransformation, UseJanusGraphGremlinQueryEnvironmentTransformation>()));
 }