Esempio n. 1
1
        static void InitializeENodeFramework()
        {
            var setting = new ConfigurationSetting
            {
                SqlDefaultConnectionString = ConfigurationManager.AppSettings["connectionString"],
                EnableGroupCommitEvent = false
            };
            var assemblies = new[]
            {
                Assembly.Load("NoteSample.Domain"),
                Assembly.Load("NoteSample.CommandHandlers"),
                Assembly.Load("NoteSample.Commands"),
                Assembly.GetExecutingAssembly()
            };
            _configuration = ECommonConfiguration
                .Create()
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .UseJsonNet()
                .RegisterUnhandledExceptionHandler()
                .CreateENode(setting)
                .RegisterENodeComponents()
                .UseSqlServerEventStore()
                .RegisterBusinessComponents(assemblies)
                .InitializeBusinessAssemblies(assemblies)
                .UseEQueue()
                .StartEQueue();

            _commandService = ObjectContainer.Resolve<ICommandService>();
            _memoryCache = ObjectContainer.Resolve<IMemoryCache>();
        }
 public InMemoryStorage()
 {
     var builder = new ServiceCollection();
     builder.AddMemoryCache();
     var provider = builder.BuildServiceProvider();
     _memoryCache = (IMemoryCache)provider.GetService(typeof(IMemoryCache));
 }
Esempio n. 3
0
        private void PriodicallyReadKey(IMemoryCache cache, TimeSpan interval)
        {
            Task.Run(async () =>
            {
                while (true)
                {
                    await Task.Delay(interval);

                    if (Random.Next(3) == 0) // 1/3 chance
                    {
                        // Allow values to expire due to sliding refresh.
                        Console.WriteLine("Read skipped, random choice.");
                    }
                    else
                    {
                        Console.Write("Reading...");
                        object result;
                        if(!cache.TryGetValue(Key, out result))
                        {
                            result = cache.Set(Key, "B", _cacheEntryOptions);
                        }
                        Console.WriteLine("Read: " + (result ?? "(null)"));
                    }
                }
            });
        }
 public DefaultCleanAggregateService(IMemoryCache memoryCache, IScheduleService scheduleService)
 {
     TimeoutSeconds = ENodeConfiguration.Instance.Setting.AggregateRootMaxInactiveSeconds;
     _memoryCache = memoryCache;
     _scheduleService = scheduleService;
     _scheduleService.StartTask("CleanAggregates", Clean, 1000, ENodeConfiguration.Instance.Setting.ScanExpiredAggregateIntervalMilliseconds);
 }
Esempio n. 5
0
 // Internal for unit testing
 internal DefaultChunkTreeCache(
     IFileProvider fileProvider,
     MemoryCacheOptions options)
 {
     _fileProvider = fileProvider;
     _chunkTreeCache = new MemoryCache(options);
 }
        public TokenHelper(IMemoryCache cache)
        {
            if (cache == null) throw new ArgumentNullException(nameof(cache), $"{nameof(cache)} cannot be null");

            _cache = cache;
            _client = new HttpClient();
        }
Esempio n. 7
0
 public ProductsService(
     IMemoryCache memoryCache,
     ISignalTokenProviderService<Product> tokenProviderService)
 {
     _memoryCache = memoryCache;
     _tokenProviderService = tokenProviderService;
 }
Esempio n. 8
0
 public QRCodeMiddleware(RequestDelegate next, IQRCodeGenerator generator, IMemoryCache cache, ILogger<QRCodeMiddleware> logger)
 {
     this.next = next;
     this.logger = logger;
     this.generator = generator;
     this.cache = cache;
 }
Esempio n. 9
0
 public HomeController(IConfigurationRoot configuration, IOptions<OtherSettings> otherSettings, ILogger<HomeController> logger, IMemoryCache memoryCache)
 {
     _configuration = configuration;
     _otherSettings = otherSettings.Value;
     _logger = logger;
     _memoryCache = memoryCache;
 }
Esempio n. 10
0
 public DefaultEventService(
     IJsonSerializer jsonSerializer,
     IScheduleService scheduleService,
     ITypeNameProvider typeNameProvider,
     IMemoryCache memoryCache,
     IAggregateRootFactory aggregateRootFactory,
     IAggregateStorage aggregateStorage,
     IEventStore eventStore,
     IMessagePublisher<DomainEventStreamMessage> domainEventPublisher,
     IOHelper ioHelper,
     ILoggerFactory loggerFactory)
 {
     _eventMailboxDict = new ConcurrentDictionary<string, EventMailBox>();
     _ioHelper = ioHelper;
     _jsonSerializer = jsonSerializer;
     _scheduleService = scheduleService;
     _typeNameProvider = typeNameProvider;
     _memoryCache = memoryCache;
     _aggregateRootFactory = aggregateRootFactory;
     _aggregateStorage = aggregateStorage;
     _eventStore = eventStore;
     _domainEventPublisher = domainEventPublisher;
     _logger = loggerFactory.Create(GetType().FullName);
     _batchSize = ENodeConfiguration.Instance.Setting.EventMailBoxPersistenceMaxBatchSize;
 }
Esempio n. 11
0
        public DefaultCommandExecutor(
            IProcessingCommandCache processingCommandCache,
            ICommandAsyncResultManager commandAsyncResultManager,
            ICommandHandlerProvider commandHandlerProvider,
            IAggregateRootTypeProvider aggregateRootTypeProvider,
            IMemoryCache memoryCache,
            IRepository repository,
            IRetryCommandService retryCommandService,
            IEventStore eventStore,
            IEventPublisher eventPublisher,
            IEventPersistenceSynchronizerProvider eventPersistenceSynchronizerProvider,
            ICommandContext commandContext,
            ILoggerFactory loggerFactory)
        {
            _processingCommandCache = processingCommandCache;
            _commandAsyncResultManager = commandAsyncResultManager;
            _commandHandlerProvider = commandHandlerProvider;
            _aggregateRootTypeProvider = aggregateRootTypeProvider;
            _memoryCache = memoryCache;
            _repository = repository;
            _retryCommandService = retryCommandService;
            _eventStore = eventStore;
            _eventPublisher = eventPublisher;
            _eventPersistenceSynchronizerProvider = eventPersistenceSynchronizerProvider;
            _commandContext = commandContext;
            _trackingContext = commandContext as ITrackingContext;
            _logger = loggerFactory.Create(GetType().Name);

            if (_trackingContext == null)
            {
                throw new Exception("command context must also implement ITrackingContext interface.");
            }
        }
Esempio n. 12
0
 /// <summary>Parameterized constructor.
 /// </summary>
 /// <param name="waitingCommandService"></param>
 /// <param name="aggregateRootTypeCodeProvider"></param>
 /// <param name="aggregateRootFactory"></param>
 /// <param name="eventStreamConvertService"></param>
 /// <param name="eventSourcingService"></param>
 /// <param name="memoryCache"></param>
 /// <param name="aggregateStorage"></param>
 /// <param name="retryCommandService"></param>
 /// <param name="eventStore"></param>
 /// <param name="eventPublisher"></param>
 /// <param name="actionExecutionService"></param>
 /// <param name="eventSynchronizerProvider"></param>
 /// <param name="loggerFactory"></param>
 public DefaultCommitEventService(
     IWaitingCommandService waitingCommandService,
     IAggregateRootTypeCodeProvider aggregateRootTypeCodeProvider,
     IAggregateRootFactory aggregateRootFactory,
     IEventStreamConvertService eventStreamConvertService,
     IEventSourcingService eventSourcingService,
     IMemoryCache memoryCache,
     IAggregateStorage aggregateStorage,
     IRetryCommandService retryCommandService,
     IEventStore eventStore,
     IEventPublisher eventPublisher,
     IActionExecutionService actionExecutionService,
     IEventSynchronizerProvider eventSynchronizerProvider,
     ILoggerFactory loggerFactory)
 {
     _waitingCommandService = waitingCommandService;
     _aggregateRootTypeCodeProvider = aggregateRootTypeCodeProvider;
     _aggregateRootFactory = aggregateRootFactory;
     _eventStreamConvertService = eventStreamConvertService;
     _eventSourcingService = eventSourcingService;
     _memoryCache = memoryCache;
     _aggregateStorage = aggregateStorage;
     _retryCommandService = retryCommandService;
     _eventStore = eventStore;
     _eventPublisher = eventPublisher;
     _actionExecutionService = actionExecutionService;
     _eventSynchronizerProvider = eventSynchronizerProvider;
     _logger = loggerFactory.Create(GetType().Name);
 }
		public CategoryController(IGanoolService ganool, IMemoryCache cache, IOptions<Settings> options)
	    {
			setting = options.Value;
			this.ganool = ganool;
			this.ganool.SiteUrl = BaseUrl;
			this.cache = cache;
	    }
Esempio n. 14
0
 public XmlBlogRepository(IHostingEnvironment env,
                             IMemoryCache memoryCache,
                             ILoggerFactory loggerFactory)
     : base(env, memoryCache)
 {
     Logger = loggerFactory.CreateLogger<XmlBlogRepository>();
 }
Esempio n. 15
0
 public SecurityController(IMemoryCache cache, ICacheFactoryStore cacheFactoryStore, ToracGolfContext dbContext, IOptions<AppSettings> configuration, ILogger<SecurityController> logger)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Configuration = configuration;
     Logger = logger;
 }
 public DataMiddleware(RequestDelegate next,
     IMemoryCache memCache,
     IService<Employee> serv)
 {
     _next = next;
     _MemoryCache = memCache;
     _service = serv;
 }
Esempio n. 17
0
 protected FileBlogRepository(IHostingEnvironment env, IMemoryCache memoryCache)
 {
     MemoryCache = memoryCache;
     PostsCacheKey = "{0}_posts";
     PostsFolder = Path.Combine("{0}", "posts", "{1}");
     _filesFolder = "/posts/{1}/files/";
     RootFolder = env.WebRootPath;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="CoreOptionsExtension" /> class with the same options as an
 ///     existing instance.
 /// </summary>
 /// <param name="copyFrom"> The <see cref="CoreOptionsExtension" /> to copy options from. </param>
 public CoreOptionsExtension([NotNull] CoreOptionsExtension copyFrom)
 {
     _internalServiceProvider = copyFrom.InternalServiceProvider;
     _model = copyFrom.Model;
     _loggerFactory = copyFrom.LoggerFactory;
     _memoryCache = copyFrom.MemoryCache;
     _isSensitiveDataLoggingEnabled = copyFrom.IsSensitiveDataLoggingEnabled;
 }
Esempio n. 19
0
 public SettingsController(IMemoryCache cache, ICacheFactoryStore cacheFactoryStore, ToracGolfContext dbContext, IAntiforgery antiforgery, IOptions<AppSettings> configuration)
 {
     DbContext = dbContext;
     Cache = cache;
     CacheFactory = cacheFactoryStore;
     Antiforgery = antiforgery;
     Configuration = configuration;
 }
 public WebDataResolver(
     IHostingEnvironment hostingEnvironment,
     IMemoryCache memoryCache,
     IOptions<StatusPageOptions> options)
 {
     this.hostingEnvironment = hostingEnvironment;
     this.memoryCache = memoryCache;
     this.options = options.Value;
 }
Esempio n. 21
0
 /// <summary>
 /// Creates a new instance of <see cref="FileVersionProvider"/>.
 /// </summary>
 /// <param name="fileProvider">The file provider to get and watch files.</param>
 /// <param name="applicationName">Name of the application.</param>
 /// <param name="cache"><see cref="IMemoryCache"/> where versioned urls of files are cached.</param>
 public FileVersionProvider(
     [NotNull] IFileProvider fileProvider,
     [NotNull] IMemoryCache cache,
     [NotNull] PathString requestPathBase)
 {
     _fileProvider = fileProvider;
     _cache = cache;
     _requestPathBase = requestPathBase;
 }
Esempio n. 22
0
 public SiteService(
     ISession session,
     IContentManager contentManager,
     IMemoryCache memoryCache)
 {
     _contentManager = contentManager;
     _session = session;
     _memoryCache = memoryCache;
 }
Esempio n. 23
0
        public LocalCache(IMemoryCache memoryCache)
        {
            if (memoryCache == null)
            {
                throw new ArgumentNullException(nameof(memoryCache));
            }

            _memCache = memoryCache;
        }
Esempio n. 24
0
 public FeatureHash(
     IFeatureManager featureManager,
     IMemoryCache memoryCache,
     ISignal signal)
 {
     _memoryCache = memoryCache;
     _featureManager = featureManager;
     _signal = signal;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SitemapService" /> class.
 /// </summary>
 /// <param name="loggingService">The logging service.</param>
 /// <param name="memoryCache">The memory cache for the application.</param>
 /// <param name="urlHelper">The URL helper.</param>
 public SitemapService(
     ILoggingService loggingService,
     IMemoryCache memoryCache,
     IUrlHelper urlHelper)
 {
     this.loggingService = loggingService;
     this.memoryCache = memoryCache;
     this.urlHelper = urlHelper;
 }
 public ContentDefinitionManager(
     ISession session,
     IMemoryCache memoryCache,
     ISignal signal)
 {
     _signal = signal;
     _memoryCache = memoryCache;
     _session = session;
 }
        /// <summary>
        /// Instantiates a new <see cref="RazorPreCompileModule"/> instance.
        /// </summary>
        /// <param name="services">The <see cref="IServiceProvider"/> for the application.</param>
        public RazorPreCompileModule(IServiceProvider services)
        {
            _appServices = services;

            // When ListenForMemoryPressure is true, the MemoryCache evicts items at every gen2 collection.
            // In DTH, gen2 happens frequently enough to make it undesirable for caching precompilation results. We'll
            // disable listening for memory pressure for the MemoryCache instance used by precompilation.
            _memoryCache = new MemoryCache(new MemoryCacheOptions { ListenForMemoryPressure = false });
        }
Esempio n. 28
0
 public ApiPostsController(ApplicationDbContext context, UserManager<ApplicationUser> userManager, MapperConfiguration mapperConfiguration
     ,IMemoryCache memoryCache, PostsCacher postsCacher)
 {
     _context = context;
     _userManager = userManager;
     _mapperConfiguration = mapperConfiguration;
     _memoryCache = memoryCache;
     _postsCacher = postsCacher;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SitemapService" /> class.
 /// </summary>
 /// <param name="loggerFactory">The logger factory.</param>
 /// <param name="memoryCache">The memory cache for the application.</param>
 /// <param name="urlHelper">The URL helper.</param>
 public SitemapService(
     ILoggerFactory loggerFactory,
     IMemoryCache memoryCache,
     IUrlHelper urlHelper)
 {
     this.logger = loggerFactory.CreateLogger<SitemapService>();
     this.memoryCache = memoryCache;
     this.urlHelper = urlHelper;
 }
 public GreetingMiddleware(RequestDelegate next,
     IMemoryCache memoryCache,
     ILogger<GreetingMiddleware> logger,
     IGreetingService greetingService)
 {
     _next = next;
     _memoryCache = memoryCache;
     _greetingService = greetingService;
     _logger = logger;
 }
Esempio n. 31
0
 public LocalMemoryCache(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
 {
     _cache = memoryCache;
     _hostingEnvironment = hostingEnvironment;
 }
 public ApiConfigurationController(MixCmsContext context, IMemoryCache memoryCache, Microsoft.AspNetCore.SignalR.IHubContext <PortalHub> hubContext)
     : base(context, memoryCache, hubContext)
 {
 }
 public RequestResponseLoggingMiddleware(RequestDelegate next, ILogger <Startup> logger, IMemoryCache cache)
 {
     _next   = next;
     _logger = logger;
     _cache  = cache;
 }
 public NewsController(IScraperService scraperService, ILogger <NewsController> logger, IMemoryCache cache)
 {
     _scraperService = scraperService;
     _logger         = logger;
     _cache          = cache;
 }
Esempio n. 35
0
 public StoreService(IStoreModule storeApi, IMemoryCache memoryCache, IApiChangesWatcher apiChangesWatcher)
 {
     _storeApi          = storeApi;
     _memoryCache       = memoryCache;
     _apiChangesWatcher = apiChangesWatcher;
 }
Esempio n. 36
0
        public RuntimeViewCompiler(
            IFileProvider fileProvider,
            RazorProjectEngine projectEngine,
            CSharpCompiler csharpCompiler,
            IList <CompiledViewDescriptor> precompiledViews,
            ILogger logger)
        {
            if (fileProvider == null)
            {
                throw new ArgumentNullException(nameof(fileProvider));
            }

            if (projectEngine == null)
            {
                throw new ArgumentNullException(nameof(projectEngine));
            }

            if (csharpCompiler == null)
            {
                throw new ArgumentNullException(nameof(csharpCompiler));
            }

            if (precompiledViews == null)
            {
                throw new ArgumentNullException(nameof(precompiledViews));
            }

            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }

            _fileProvider   = fileProvider;
            _projectEngine  = projectEngine;
            _csharpCompiler = csharpCompiler;
            _logger         = logger;


            _normalizedPathCache = new ConcurrentDictionary <string, string>(StringComparer.Ordinal);

            // This is our L0 cache, and is a durable store. Views migrate into the cache as they are requested
            // from either the set of known precompiled views, or by being compiled.
            _cache = new MemoryCache(new MemoryCacheOptions());

            // We need to validate that the all of the precompiled views are unique by path (case-insensitive).
            // We do this because there's no good way to canonicalize paths on windows, and it will create
            // problems when deploying to linux. Rather than deal with these issues, we just don't support
            // views that differ only by case.
            _precompiledViews = new Dictionary <string, CompiledViewDescriptor>(
                precompiledViews.Count,
                StringComparer.OrdinalIgnoreCase);

            foreach (var precompiledView in precompiledViews)
            {
                logger.ViewCompilerLocatedCompiledView(precompiledView.RelativePath);

                if (!_precompiledViews.ContainsKey(precompiledView.RelativePath))
                {
                    // View ordering has precedence semantics, a view with a higher precedence was
                    // already added to the list.
                    _precompiledViews.Add(precompiledView.RelativePath, precompiledView);
                }
            }

            if (_precompiledViews.Count == 0)
            {
                logger.ViewCompilerNoCompiledViewsFound();
            }
        }
Esempio n. 37
0
 public CategoryMenuComponent(IPartsUnlimitedContext context, IMemoryCache memoryCache)
 {
     _db    = context;
     _cache = memoryCache;
 }
Esempio n. 38
0
 public UserTokenCacheProviderFactory(IMemoryCache memoryCache)
 {
     _memoryCache = memoryCache;
 }
Esempio n. 39
0
 public PersonService(IMemoryCache memoryCache, IMapper mapper)
 {
     _cache  = memoryCache;
     _mapper = mapper;
 }
 public CacheController(IMemoryCache cache)
 {
     this.cache = cache;
 }
Esempio n. 41
0
 public CacheHelper(IMemoryCache objCache)
 {
     _objCache = objCache;
 }
Esempio n. 42
0
 public ConfigurationManager(SettingValueManager settingValueManager,
                             IMemoryCache memoryCache)
 {
     _settingValueManager = settingValueManager;
     _memoryCache         = memoryCache;
 }
Esempio n. 43
0
 public MemoryCacheManager()
 {
     _cache = ServiceTool.ServiceProvider.GetService <IMemoryCache>();
 }
 public BinanceCacheService(IMemoryCache memoryCache)
 {
     _memoryCache = memoryCache;
 }
 public ReportViewerController(IMemoryCache memoryCache, IHostingEnvironment hostingEnvironment)
 {
     _cache = memoryCache;
     _hostingEnvironment = hostingEnvironment;
 }
Esempio n. 46
0
 public ServiceHelper(IMemoryCache memoryCache, IConfiguration configuration)
 {
     _cache        = memoryCache;
     _testUsername = configuration["SwgohHelpAuth:username"];
     _testPassword = configuration["SwgohHelpAuth:password"];
 }
Esempio n. 47
0
 public StoreWareDomainService(IRepository <StoreWareEntity> wareRepository, IMemoryCache cache, IMediatorHandler bus) : base(wareRepository, cache, bus)
 {
     _wareRepository = wareRepository;
 }
Esempio n. 48
0
 public ApiConfigurationController(IMemoryCache memoryCache, Microsoft.AspNetCore.SignalR.IHubContext <Hub.PortalHub> hubContext) : base(memoryCache, hubContext)
 {
 }
Esempio n. 49
0
 public MemoryCacheProvider(IMemoryCache cache, IOptions <MemoryCacheOptions> options)
 {
     _cache   = cache;
     _options = options.Value;
 }
Esempio n. 50
0
 public SyntaxesController(IMemoryCache memoryCache, SeedService seedService, SyntaxService syntaxService) :
     base(memoryCache, seedService) => this.syntaxService = syntaxService;
 static MemoryTokenCache()
 {
     _cache = new MemoryCache(new MemoryCacheOptions());
 }
Esempio n. 52
0
 public WalletController(IMemoryCache memoryCache)
 {
     _cache = memoryCache;
 }
Esempio n. 53
0
 public ValuesController(IHostingEnvironment environment, IMemoryCache caching, ILogger <ValuesController> logger)
 {
     _environment = environment;
     _caching     = caching;
     _logger      = logger;
 }
 public CustomUserManager(IUserStore <User> userStore, IStoreModule storeApi, IStorefrontSecurity commerceCoreApi, ISecurity platformSecurityApi, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <User> passwordHasher,
                          IEnumerable <IUserValidator <User> > userValidators, IEnumerable <IPasswordValidator <User> > passwordValidators,
                          ILookupNormalizer keyNormalizer, IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager <User> > logger, IMemoryCache memoryCache)
     : base(userStore, optionsAccessor, passwordHasher, userValidators, passwordValidators, keyNormalizer, errors, services, logger)
 {
     _storeApi            = storeApi;
     _commerceCoreApi     = commerceCoreApi;
     _platformSecurityApi = platformSecurityApi;
     _memoryCache         = memoryCache;
 }
Esempio n. 55
0
 public ColumnAliasManager(IUnitOfWork unitOfWork, IMemoryCache cache)
 {
     _unitOfWork = unitOfWork;
     _cache = cache;
     _columnAliaRepository = _unitOfWork.GetRepository<AAColumnAlia>();
 }
Esempio n. 56
0
        /// <summary>
        /// 构造一个 <see cref="MigrationCommandExecutionValidator"/>。
        /// </summary>
        /// <param name="memoryCache">给定的 <see cref="IMemoryCache"/>。</param>
        public MigrationCommandExecutionValidator(IMemoryCache memoryCache)
        {
            MemoryCache = memoryCache.NotNull(nameof(memoryCache));

            _defaultEncoding = ExtensionSettings.Preference.DefaultEncoding;
        }
 public RulesController(IMemoryCache memoryCache, RuleService ruleService) : base(memoryCache) =>
     this.ruleService = ruleService;
Esempio n. 58
0
 public ActionRequirementFilter(string operation, IHttpContextAccessor httpContextAccessor, IMemoryCache cache)
 {
     _operation = operation;
     _httpContextAccessor = httpContextAccessor;
     _cache = cache;
 }
Esempio n. 59
0
 public V2exSpider(HttpClient http, IMemoryCache cache) : base(http, cache)
 {
     Http.BaseAddress = new Uri("https://www.v2ex.com");
     Http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Mobile Safari/537.36");
 }
Esempio n. 60
0
 public ProductsViewComponent(ProductsService productsService, IMemoryCache cache)
 {
     ProductsService = productsService;
     Cache           = cache;
 }