Exemple #1
0
        public DonutContext(IRedisCacher cacher, Data.DataIntegration integration, IServiceProvider serviceProvider)
        {
            _cacher               = cacher;
            ApiAuth               = integration.APIKey;
            CacheRunInterval      = 10;
            _currentCacheRunIndex = 0;
            Integration           = integration;
            CurrentCache          = new ConcurrentDictionary <string, List <HashEntry> >();
            ConfigureCacheMap();
            Prefix = $"integration_context:{Integration.Id}";
            new ContextSetDiscoveryService(this, serviceProvider).Initialize();
            _cachingService = new CachingPersistеnceService(this);
            if (integration != null && !string.IsNullOrEmpty(integration.FeaturesCollection))
            {
                _encoder = FieldEncoder.Factory.Create(Integration);
//                var dbConfig = DBConfig.GetGeneralDatabase();
//                var mongoList = new MongoList(dbConfig, integration.FeaturesCollection);//Make sure the collection exists
//                var murlBuilder = new MongoUrlBuilder("");
//                murlBuilder.AuthenticationSource = "admin";
//                var murl = murlBuilder.ToMongoUrl();
//                var connection = new MongoClient(murl);
//                var database = connection.GetDatabase("");
//IMongoDatabase db = MongoHelper.GetDatabase();
//db.CreateCollection(integration.FeaturesCollection);
            }
        }
Exemple #2
0
        public DonutBuilder(DataIntegration integration, IRedisCacher cacher, IServiceProvider serviceProvider)
        {
            _tContext        = typeof(TContext);
            _serviceProvider = serviceProvider;
            var assembly     = Assembly.GetExecutingAssembly();
            var resourceName = "Donut.Lex.Templates.Donutfile.txt";

            _cacher      = cacher;
            _integration = integration;
            using (Stream stream = assembly.GetManifestResourceStream(resourceName))
                using (StreamReader reader = new StreamReader(stream))
                {
                    _template = reader.ReadToEnd();
                }
        }
Exemple #3
0
        public static IDonutBuilder Create <TData>(Type donutType,
                                                   Type donutContextType,
                                                   IIntegration integration, IRedisCacher cacher, IServiceProvider serviceProvider)
            where TData : class, IIntegratedDocument
        {
            var builderType = typeof(DonutBuilder <, ,>).MakeGenericType(new Type[] { donutType, donutContextType, typeof(TData) });
            //DataIntegration integration, RedisCacher cacher, IServiceProvider serviceProvider
            var builderCtor = builderType.GetConstructor(new Type[]
                                                         { typeof(Data.DataIntegration), typeof(IRedisCacher), typeof(IServiceProvider) });

            if (builderCtor == null)
            {
                throw new Exception("DonutBuilder<> has invalid ctor parameters.");
            }
            var builder = Activator.CreateInstance(builderType, integration, cacher, serviceProvider);

            return(builder as IDonutBuilder);
        }
 public TestRedisManager(IOptionsFactory <RedisOptions> options)
 {
     _redisOptions = options.Create(this.GetType().Name);
     _redisCacher  = new RedisCacher(_redisOptions);
     _redisCacher.Connect();
 }
Exemple #5
0
 public CachingPersistеnceService(ISetCollection ctx)
 {
     _context = ctx;
     _cacher  = ctx.Database;
     _rand    = new Random();
 }