public NexusContext(IContextValueProvider valueProvider)
 {
     ValueProvider                 = valueProvider;
     _correlationId                = new OneValueProvider <string>(ValueProvider, "NexusCorrelationId");
     _parentExecutionId            = new OneValueProvider <string>(ValueProvider, "NexusParentExecutionId");
     _executionId                  = new OneValueProvider <string>(ValueProvider, "NexusExecutionId");
     _callingClientName            = new OneValueProvider <string>(ValueProvider, "CallingClientName");
     _clientTenant                 = new OneValueProvider <Tenant>(ValueProvider, "TenantId");
     _leverConfiguration           = new OneValueProvider <ILeverConfiguration>(ValueProvider, "LeverConfigurationId");
     _clientPrincipal              = new OneValueProvider <IPrincipal>(ValueProvider, "ClientPrincipal");
     _userPrincipal                = new OneValueProvider <IPrincipal>(ValueProvider, "UserPrincipal");
     _isInBatchLogger              = new OneValueProvider <bool>(ValueProvider, "IsInBatchLogger");
     _nexusTestContext             = new OneValueProvider <string>(ValueProvider, "NexusTestContext");
     _managedAsynchronousRequestId = new OneValueProvider <string>(ValueProvider, "ManagedAsynchronousRequestId");
 }
        protected object GetValueFromContext(string key, ValidationContext validationContext, bool allowNullValues = false)
        {
            if (!(validationContext.ObjectInstance is IContextValueProvider))
            {
                throw new InvalidOperationException("ContextProvidedRangeAttribute can only be used on a property belonging to a class that implements IContextValueProvider.");
            }

            IContextValueProvider provider = (IContextValueProvider)validationContext.ObjectInstance;
            object value;

            value = provider.GetValue(key);
            if (!allowNullValues && value == null)
            {
                throw new InvalidOperationException(string.Format(MISSING_VALUE_KEY_ERROR_MSG, key));
            }
            return(value);
        }
Esempio n. 3
0
 public AddUserAuthorization()
 {
     _provider = new AsyncLocalContextValueProvider();
 }
Esempio n. 4
0
 public void Initialize()
 {
     FulcrumApplicationHelper.UnitTestSetup(nameof(TestAsyncLocalContextValueProvider));
     _provider = new AsyncLocalContextValueProvider();
 }
 public AddTranslatedUserId()
 {
     _provider = new AsyncLocalContextValueProvider();
 }