public static IRepositoryBuilder BuildInMemoryRepository(this IRepositoryBuilder repositoryBuilder, InitialData initialData, InMemoryIndex initialIndex) { if (initialData == null) { throw new ArgumentNullException(nameof(initialData)); } if (initialIndex == null) { throw new ArgumentNullException(nameof(initialIndex)); } // Precedence: if a service is registered in the collection, use that // instead of creating instances locally. var services = (repositoryBuilder as RepositoryBuilder)?.Services; if (services?.GetService <DataProvider>() is InMemoryDataProvider dataProvider) { // If there is an instance in the container, use that. We have to set // these instances manually instead of using the extension method so that // we do not overwrite the store instance. Providers.Instance.DataProvider = dataProvider; Providers.Instance.DataStore = services.GetService <IDataStore>(); } else { dataProvider = new InMemoryDataProvider(); repositoryBuilder.UseDataProvider(dataProvider); } Providers.Instance.ResetBlobProviders(); var searchEngine = services?.GetService <ISearchEngine>() ?? new InMemorySearchEngine(initialIndex); repositoryBuilder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseInitialData(initialData) .UseSharedLockDataProviderExtension(new InMemorySharedLockDataProvider()) .UseExclusiveLockDataProviderExtension(new InMemoryExclusiveLockDataProvider()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dataProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .AddBlobProvider(new InMemoryBlobProvider()) .UseAccessTokenDataProviderExtension(new InMemoryAccessTokenDataProvider()) .UsePackagingDataProviderExtension(new InMemoryPackageStorageProvider()) .UseSearchEngine(searchEngine) .UseSecurityDataProvider(GetSecurityDataProvider(dataProvider)) .UseSecurityMessageProvider(new DefaultMessageProvider(new MessageSenderManager())) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .StartWorkflowEngine(false); var statDp = services?.GetService <IStatisticalDataProvider>() as InMemoryStatisticalDataProvider ?? new InMemoryStatisticalDataProvider(); repositoryBuilder.UseStatisticalDataProvider(statDp); Providers.Instance.PropertyCollector = new EventPropertyCollector(); return(repositoryBuilder); }
public static IRepositoryBuilder BuildInMemoryRepository(this IRepositoryBuilder repositoryBuilder, InitialData initialData, InMemoryIndex initialIndex) { if (initialData == null) { throw new ArgumentNullException(nameof(initialData)); } if (initialIndex == null) { throw new ArgumentNullException(nameof(initialIndex)); } var dataProvider = new InMemoryDataProvider(); repositoryBuilder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseDataProvider(dataProvider) .UseInitialData(initialData) .UseSharedLockDataProviderExtension(new InMemorySharedLockDataProvider()) .UseExclusiveLockDataProviderExtension(new InMemoryExclusiveLockDataProvider()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dataProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .UseAccessTokenDataProviderExtension(new InMemoryAccessTokenDataProvider()) .UsePackagingDataProviderExtension(new InMemoryPackageStorageProvider()) .UseSearchEngine(new InMemorySearchEngine(initialIndex)) .UseSecurityDataProvider(GetSecurityDataProvider(dataProvider)) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .StartWorkflowEngine(false); Providers.Instance.PropertyCollector = new EventPropertyCollector(); return(repositoryBuilder); }
/// <summary> /// Adds the registered IEventLogger instance to the repository builder. /// </summary> public static IRepositoryBuilder UseLogger(this IRepositoryBuilder repositoryBuilder, IServiceProvider provider) { var logger = provider.GetService <IEventLogger>(); if (logger != null) { repositoryBuilder.UseLogger(logger); } return(repositoryBuilder); }
/// <summary> /// Adds the registered IEventLogger instance to the repository builder. /// </summary> public static IRepositoryBuilder UseLogger(this IRepositoryBuilder repositoryBuilder, IServiceProvider provider) { var logger = provider.GetService <IEventLogger>(); if (logger != null) { repositoryBuilder.UseLogger(logger); } // stores a logger instance for later use var genericLogger = provider.GetService <ILogger <SnILogger> >(); if (genericLogger != null) { repositoryBuilder.SetProvider <ILogger <SnILogger> >(genericLogger); } return(repositoryBuilder); }
public static IRepositoryBuilder BuildInMemoryRepository(this IRepositoryBuilder repositoryBuilder, InitialData initialData, InMemoryIndex initialIndex) { if (initialData == null) { throw new ArgumentNullException(nameof(initialData)); } if (initialIndex == null) { throw new ArgumentNullException(nameof(initialIndex)); } // Precedence: if a service is registered in the collection, use that // instead of creating instances locally. var services = (repositoryBuilder as RepositoryBuilder)?.Services; if (services == null) { throw new ApplicationException("IServiceProvider cannot be found"); } var dataProvider = services.GetRequiredService <DataProvider>(); Providers.Instance.ResetBlobProviders(new ConnectionStringOptions()); repositoryBuilder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseInitialData(initialData) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dataProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .AddBlobProvider(new InMemoryBlobProvider()) .UseSearchEngine(services.GetRequiredService <ISearchEngine>()) .StartWorkflowEngine(false); var statDp = services?.GetService <IStatisticalDataProvider>() as InMemoryStatisticalDataProvider ?? new InMemoryStatisticalDataProvider(); repositoryBuilder.UseStatisticalDataProvider(statDp); return(repositoryBuilder); }
public static IRepositoryBuilder BuildInMemoryRepository(this IRepositoryBuilder repositoryBuilder) { var dataProvider = new InMemoryDataProvider(); repositoryBuilder .UseLogger(new DebugWriteLoggerAdapter()) .UseTracer(new SnDebugViewTracer()) .UseDataProvider(dataProvider) .UseInitialData(InitialData.Load(SenseNetServicesData.Instance)) .UseSharedLockDataProviderExtension(new InMemorySharedLockDataProvider()) .UseBlobMetaDataProvider(new InMemoryBlobStorageMetaDataProvider(dataProvider)) .UseBlobProviderSelector(new InMemoryBlobProviderSelector()) .UseAccessTokenDataProviderExtension(new InMemoryAccessTokenDataProvider()) .UsePackagingDataProviderExtension(new InMemoryPackageStorageProvider()) .UseSearchEngine(new InMemorySearchEngine(GetInitialIndex())) .UseSecurityDataProvider(GetSecurityDataProvider(dataProvider)) .UseElevatedModificationVisibilityRuleProvider(new ElevatedModificationVisibilityRule()) .StartWorkflowEngine(false); Providers.Instance.PropertyCollector = new EventPropertyCollector(); return(repositoryBuilder); }
protected override void BuildRepository(IRepositoryBuilder repositoryBuilder) { base.BuildRepository(repositoryBuilder); repositoryBuilder.UseLogger(new ApplicationInsightsLogger()); }