private static IContextStorageFactory CreateFactoryForTransactionContext(IContextStorage <IInternalTransaction> transactionContext) { var transactionContextFactory = Mock.Create <IContextStorageFactory>(); Mock.Arrange(() => transactionContextFactory.CreateContext <IInternalTransaction>(Arg.AnyString)).Returns(transactionContext); return(transactionContextFactory); }
public IContextStorage <T> Get() { IContextStorage <T> storage = null; string storageName = this.platformSetting.ContextStorage; storage = func(storageName); return(storage as IContextStorage <T>); }
public override bool AttachToAsync() { var currentValue = _currentContextStorage.GetData(); _currentContextStorage = _asyncContextStorage; _currentContextStorage.SetData(currentValue); return(true); }
protected override void Arrange() { Given <IContextStorage>(new HashtableContextStorage()); Given <ISession>(); contextstorage = new HashtableContextStorage(); Supplied <IReadOnlyList <AuthorizationFilterDetails> >(CreateTestParameters()); authProvider = new AuthorizationFilterContextProvider(contextstorage); }
/// <summary> /// Sets up the context with the appropriate dependencies. /// </summary> /// <param name="contextStorage">The context storage for the dependencies.</param> /// <param name="logger">The logger for the system.</param> /// <param name="networkContext">The network context to be used through the application.</param> public static void Setup(IContextStorage contextStorage, ILogger logger, INetworkContext networkContext) { _contextStorage = contextStorage; _contextStorage.SetData(StorageKeyLogger, logger); _contextStorage.SetData(StorageKeyNetworkContext, networkContext); Keys.Clear(); Keys.Add(StorageKeyLogger); Keys.Add(StorageKeyNetworkContext); }
public ProductDeserializer(IFieldService fieldService, IServiceFactory serviceFactory, ICacheItemWatcher cacheItemWatcher, IContextStorage contextStorage, IConnectionProvider connectionProvider) { _fieldService = fieldService; _contentService = serviceFactory.GetContentService(); _cacheItemWatcher = cacheItemWatcher; _contextStorage = contextStorage; _customer = connectionProvider.GetCustomer(); }
public ReadOnlyArticleServiceAdapter(ArticleService articleService, IConnectionProvider connectionProvider, IContextStorage contextStorage) { if (articleService == null) { throw new ArgumentNullException("articleService"); } ArticleService = articleService; QpCustomer = connectionProvider.GetCustomer(); ContextStorage = contextStorage; }
private SessionsContainer GetSessionsContainer() { IContextStorage <SessionsContainer> storage = this.GetContextStorage(); SessionsContainer container = storage.Get(); if (container == null) { container = new SessionsContainer(); storage.Store(container); } return(container); }
public TransactionService(IEnumerable <IContextStorageFactory> factories, ITimerFactory timerFactory, ICallStackManagerFactory callStackManagerFactory, IDatabaseService databaseService, ITracePriorityManager tracePriorityManager, IDatabaseStatementParser databaseStatementParser, IErrorService errorService, IDistributedTracePayloadHandler distributedTracePayloadHandler, IAttributeDefinitionService attribDefSvc) { _sortedPrimaryContexts = GetPrimaryTransactionContexts(factories); _asyncContext = GetAsyncTransactionContext(factories); _timerFactory = timerFactory; _callStackManagerFactory = callStackManagerFactory; _databaseService = databaseService; _tracePriorityManager = tracePriorityManager; _databaseStatementParser = databaseStatementParser; _errorService = errorService; _distributedTracePayloadHandler = distributedTracePayloadHandler; _attribDefSvc = attribDefSvc; }
public void SetUp() { _lowPriorityTransactionContext = Mock.Create <IContextStorage <IInternalTransaction> >(); Mock.Arrange(() => _lowPriorityTransactionContext.Priority).Returns(1); DictionaryTransactionContext(_lowPriorityTransactionContext); _highPriorityTransactionContext = Mock.Create <IContextStorage <IInternalTransaction> >(); Mock.Arrange(() => _highPriorityTransactionContext.Priority).Returns(2); DictionaryTransactionContext(_highPriorityTransactionContext); var factory1 = CreateFactoryForTransactionContext(_highPriorityTransactionContext); var factory2 = CreateFactoryForTransactionContext(_lowPriorityTransactionContext); IAttributeDefinitionService _attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f)); _transactionService = new TransactionService(new[] { factory1, factory2 }, Mock.Create <ITimerFactory>(), Mock.Create <ICallStackManagerFactory>(), Mock.Create <IDatabaseService>(), Mock.Create <ITracePriorityManager>(), Mock.Create <IDatabaseStatementParser>(), Mock.Create <IErrorService>(), Mock.Create <IDistributedTracePayloadHandler>(), _attribDefSvc); }
private IInternalTransaction TryGetInternalTransaction(IContextStorage <IInternalTransaction> transactionContext) { try { if (transactionContext == null) { return(null); } return(transactionContext.GetData()); } catch (Exception exception) { Log.Error($"ITransactionContext threw an exception when calling GetData with {TransactionContextKey}: {exception}"); return(null); } }
private static void DictionaryTransactionContext(IContextStorage <IInternalTransaction> transactionContext) { const string key = "TEST"; var dictionary = new Dictionary <string, object>(); Mock.Arrange(() => transactionContext.CanProvide).Returns(true); Mock.Arrange(() => transactionContext.SetData((IInternalTransaction)Arg.AnyObject)).DoInstead((object value) => { dictionary[key] = value; }); Mock.Arrange(() => transactionContext.GetData()).Returns(() => { if (!dictionary.ContainsKey(key)) { return(null); } object value; dictionary.TryGetValue(key, out value); return(value as IInternalTransaction); }); }
public SnapshotContextProvider(IContextStorage contextStorage) { _contextStorage = contextStorage; }
/// <summary> /// Initializes a new instance of the <see cref="AuthorizationFilterContextProvider" /> class using the specified context storage. /// </summary> /// <param name="contextStorage">The component to be used to store the contextual data.</param> public AuthorizationFilterContextProvider(IContextStorage contextStorage) { _contextStorage = contextStorage; }
public CachedReadOnlyArticleServiceAdapter(ArticleService articleService, IConnectionProvider connectionProvider, IContextStorage contextStorage, ILogger logger) : base(articleService, connectionProvider, contextStorage) { _logger = logger; }
public FeaturesDataAccessor(IContextStorage contextStorage) { _contextStorage = contextStorage; }
public SyncToAsyncCallStackManager(IContextStorage <int?> asyncContextStorage) { _asyncContextStorage = asyncContextStorage; _currentContextStorage = new SynchronousContextStorage(); }
public SchoolYearContextProvider(IContextStorage contextStorage) { this.contextStorage = contextStorage; }
public InstanceIdContextProvider(IContextStorage contextStorage) { this.contextStorage = contextStorage; }
public TaskDataAccessor(IContextStorage contextStorage) { _contextStorage = contextStorage; }
public ApiKeyContextProvider(IContextStorage contextStorage) { _contextStorage = contextStorage; }
/// <summary> /// Sets the context storage to use for this type of context. /// </summary> /// <param name="contextStorage">The context storage implementation.</param> public static void SetContextStorage(IContextStorage contextStorage) { _contextStorage = contextStorage; }
private static void ThrowingTransactionContext(IContextStorage <IInternalTransaction> transactionContext) { Mock.Arrange(() => transactionContext.CanProvide).Returns(true); Mock.Arrange(() => transactionContext.SetData((IInternalTransaction)Arg.AnyObject)).Throws <Exception>(); Mock.Arrange(() => transactionContext.GetData()).Throws <Exception>(); }
public ArticleServiceAdapter(ArticleService articleService, IConnectionProvider connectionProvider, IContextStorage contextStorage, IIdentityProvider provider) : base(articleService, connectionProvider, contextStorage) { _provider = provider; }
public PermissionsDataAccessor(IContextStorage contextStorage) { _contextStorage = contextStorage; }
static ContextStorage() { ContextStorageImplementation = new InternalContextStorage(); }
public UsersDataAccessor(IContextStorage contextStorage) { _contextStorage = contextStorage; }
public AsyncCallStackManagerFactory(IContextStorageFactory factory) { this._storageContext = factory.CreateContext <int?>("NewRelic.ParentObject"); }
/// <summary> /// Initializes a new instance of the <see cref="HttpContextStorage"/> class with a secondary /// <see cref="IContextStorage"/> implementation to use in scenarios where <see cref="HttpContext.Current"/> /// is null (such as in background Tasks). /// </summary> /// <param name="next">The secondary context storage to use when <see cref="HttpContext.Current"/> is null.</param> public HttpContextStorage(IContextStorage next) { _next = next; }
public EmployeeModelBinder(IContextStorage contextStorage) { _contextStorage = contextStorage; }
public ProjectsDataAccessor(IContextStorage contextStorage) { _contextStorage = contextStorage; }