public bool CanBeAccessedIn(IScope scope) { for (IScope?currScope = scope; currScope != null; currScope = currScope.ContainingScope) { if (ContainingScope == currScope) { return(true); } } return(false); }
protected BaseViewModel(IScopeFactory?scopeFactory = null) { if (scopeFactory != null) { _scope = scopeFactory.CreateScope(); } _logger = _scope?.Resolve <ILoggerFactory>()?.CreateLogger(GetType().Name) ?? new LoggerFactory(new[] { new DebugLoggerProvider() }).CreateLogger(GetType().Name); CoreDispatcher.AddHandlerToDispatcher(this); }
/// <summary> /// Create a new builder for building configuration. /// </summary> public DispatcherConfigurationBuilder(IScopeFactory?scopeFactory = null) { _singleEventConfigs = new List <SingleEventTypeConfiguration>(); _multipleEventConfigs = new List <MultipleEventTypeConfiguration>(); _singleCommandConfigs = new List <SingleCommandTypeConfiguration>(); _multipleCommandConfigs = new List <MultipleCommandTypeConfiguration>(); if (scopeFactory != null) { _scope = scopeFactory.CreateScope(); } }
public TypeSpecsFolderNodeImpl(ITreeNodeGroup treeNodeGroup, Dictionary <ITypeDefOrRef, TypeRefInfo> typeDict) { TreeNodeGroup = treeNodeGroup; this.typeDict = typeDict; foreach (var kv in typeDict) { scope = kv.Key.Scope; if (!(scope is null)) { break; } } }
public FieldReferencesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, Dictionary <MemberRef, MemberRef> fieldDict) { TreeNodeGroup = treeNodeGroup; this.fieldDict = fieldDict; foreach (var kv in fieldDict) { scope = kv.Key.DeclaringType?.Scope; if (!(scope is null)) { break; } } }
public EventReferencesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, Dictionary <IMethod, HashSet <IMethod> > eventDict) { TreeNodeGroup = treeNodeGroup; this.eventDict = eventDict; foreach (var kv in eventDict) { scope = kv.Key.DeclaringType?.Scope; if (!(scope is null)) { break; } } }
public PropertyReferencesFolderNodeImpl(ITreeNodeGroup treeNodeGroup, Dictionary <IMethod, HashSet <IMethod> > propertyDict) { TreeNodeGroup = treeNodeGroup; this.propertyDict = propertyDict; foreach (var kv in propertyDict) { scope = kv.Key.DeclaringType?.Scope; if (scope is not null) { break; } } }
/// <summary> /// Create a new dispatcher instance. /// </summary> /// <param name="configuration">Dispatcher configuration.</param> /// <param name="scopeFactory">Factory of DI scope.</param> public BaseDispatcher(DispatcherConfiguration configuration, IScopeFactory?scopeFactory = null) { s_Config = configuration ?? DispatcherConfiguration.Current; if (scopeFactory != null) { s_PrivateScope = scopeFactory.CreateScope(); } s_Logger = s_Scope?.Resolve <ILoggerFactory>()?.CreateLogger <BaseDispatcher>() ?? new LoggerFactory().CreateLogger <BaseDispatcher>(); }
public InMemoryCommandBus(InMemoryCommandBusConfiguration?configuration = null, IScopeFactory?scopeFactory = null) { if (scopeFactory != null) { _scope = scopeFactory.CreateScope(); } _logger = _scope?.Resolve <ILoggerFactory>()?.CreateLogger <InMemoryCommandBus>() ?? new LoggerFactory(new[] { new DebugLoggerProvider() }).CreateLogger <InMemoryCommandBus>(); _config = configuration ?? InMemoryCommandBusConfiguration.Default; }
public InMemoryEventBus(InMemoryEventBusConfiguration?configuration = null, IScopeFactory?scopeFactory = null) { InitHandlersCollection(new string[0]); if (scopeFactory != null) { _scope = scopeFactory.CreateScope(); } _logger = _scope?.Resolve <ILoggerFactory>()?.CreateLogger <InMemoryEventBus>() ?? new LoggerFactory().CreateLogger <InMemoryEventBus>(); _handlers_HandleMethods = new Dictionary <Type, MethodInfo>(); _config = configuration ?? InMemoryEventBusConfiguration.Default; }
private void SetCallContextScope(IScope?value) { ConcurrentStack <IScope>?stack = s_scopeStack.Value; #if DEBUG_SCOPES // first, null-register the existing value if (stack != null && stack.TryPeek(out IScope ambientScope)) { RegisterContext(ambientScope, null); } // then register the new value if (value != null) { RegisterContext(value, "call"); } #endif if (value == null) { if (stack != null) { stack.TryPop(out _); } } else { #if DEBUG_SCOPES _logger.LogDebug("AddObject " + value.InstanceId.ToString("N").Substring(0, 8)); #endif if (stack == null) { stack = new ConcurrentStack <IScope>(); } stack.Push(value); s_scopeStack.Value = stack; } }
/// <summary> /// Run a query in transaction mode. /// </summary> /// <typeparam name="T">The type of the result. Use <see cref="object"/> for queries with no results.</typeparam> /// <param name="statement">The statement to execute.</param> /// <param name="configure">An action to configure the options for this query.</param> /// <param name="scope">The scope</param> /// <returns>A <see cref="SingleQueryTransactionResult{T}"/> with the query results, if any.</returns> /// <remarks>IMPORTANT: Any KV operations after this query will be run via the query engine, which has performance implications.</remarks> public static async Task <IQueryResult <T> > QueryAsync <T>(this AttemptContext ctx, string statement, Action <TransactionQueryOptions> configure, IScope?scope = null) { var options = new TransactionQueryOptions(); if (configure != null) { configure(options); } return(await ctx.QueryAsync <T>(statement, options, scope).CAF()); }
/// <summary> /// Run a single query as a transaction. /// </summary> /// <typeparam name="T">The type of the result. Use <see cref="object"/> for queries with no results.</typeparam> /// <param name="statement">The statement to execute.</param> /// <param name="configure">An action to configure this transaction.</param> /// <param name="scope">The scope</param> /// <returns>A <see cref="SingleQueryTransactionResult{T}"/> with the query results, if any.</returns> public static async Task <SingleQueryTransactionResult <T> > QueryAsync <T>(this Transactions transactions, string statement, Action <SingleQueryTransactionConfigBuilder>?configure = null, IScope?scope = null) { var singleConfig = SingleQueryTransactionConfigBuilder.Create(); if (configure != null) { configure(singleConfig); } return(await transactions.QueryAsync <T>(statement, singleConfig, scope).CAF()); }
/// <summary> /// Creates a new <see cref="TestScopeFactory"/> instance with a definition of <see cref="IScope"/>. /// </summary> /// <param name="providedScope">Scope to use when factory is called.</param> public TestScopeFactory(IScope providedScope) { _providedScope = providedScope; }
public bool Equals(IScope?x, IScope?y) => AreEquals(x, y);
/// <inheritdoc /> public bool Equals(IScope?other) { return(Equals(ScopeServiceProvider, other?.ScopeServiceProvider)); }