Esempio n. 1
0
        public ElasticClientProvider(ElasticConfigration configration)
        {
            Uri      = configration.Uri;
            Index    = configration.Index;
            UserName = configration.UserName;
            Password = configration.Password;

            Client = new ElasticClient(Generator());
        }
Esempio n. 2
0
        public static IServiceCollection AddElastic(this IServiceCollection services, Action <ElasticConfigration> configurations)
        {
            if (configurations is null)
            {
                throw new ArgumentNullException(nameof(configurations));
            }
            var newOptions = new ElasticConfigration();

            configurations.Invoke(newOptions);

            services.AddSingleton(new ElasticClientProvider(newOptions));
            services.AddSingleton(typeof(ISearch <>), (typeof(Search <>)));
            services.AddSingleton(typeof(IHelperFunc), (typeof(HelperFunc)));

            return(services);
        }