/// <summary> /// Initializes a new instance of the <see cref="SqlWorkflowInstanceStore"/> class. /// </summary> /// <param name="serializerSettingsProvider">The serializer settings provider for the store.</param> /// <param name="connectionFactory">A factory method to create a sqlconnection for the workflow store.</param> public SqlWorkflowInstanceStore( IJsonSerializerSettingsProvider serializerSettingsProvider, Func <ValueTask <SqlConnection> > connectionFactory) { this.connectionFactory = connectionFactory ?? throw new ArgumentNullException(nameof(connectionFactory)); this.serializerSettingsProvider = serializerSettingsProvider; }
/// <summary> /// Creates the workflow. /// </summary> /// <param name="id">Id to use for this workflow.</param> /// <param name="externalServiceUrl">External URL to invoke.</param> /// <param name="serviceIdentityTokenSource">The token source to use when authenticating to external services.</param> /// <param name="serializerSettingsProvider">The serialization settings provider.</param> /// <param name="externalServiceActionLogger">The logger for <see cref="InvokeExternalServiceAction"/>s.</param> /// <returns>The workflow definition.</returns> public static Workflow Create( string id, string externalServiceUrl, IServiceIdentityAccessTokenSource serviceIdentityTokenSource, IJsonSerializerSettingsProvider serializerSettingsProvider, ILogger <InvokeExternalServiceAction> externalServiceActionLogger) { var workflow = new Workflow( id, "External Action workflow", "Simple workflow using an external action"); WorkflowState waitingToRun = workflow.CreateState(displayName: "Waiting to run"); WorkflowState done = workflow.CreateState(displayName: "Done"); workflow.SetInitialState(waitingToRun); WorkflowTransition transition = waitingToRun.CreateTransition(done); var action = new InvokeExternalServiceAction( serviceIdentityTokenSource, serializerSettingsProvider, externalServiceActionLogger) { Id = Guid.NewGuid().ToString(), AuthenticateWithManagedServiceIdentity = true, MsiAuthenticationResource = "foobar", ExternalUrl = externalServiceUrl, ContextItemsToInclude = new[] { "include1", "include2" }, }; transition.Actions.Add(action); return(workflow); }
/// <summary> /// Initializes a new instance of the <see cref="CreateWorkflowActivity"/> class. /// </summary> /// <param name="serializerSettingsProvider">The serialization settings provider.</param> /// <param name="engineClient">The current client.</param> public CreateWorkflowActivity( IJsonSerializerSettingsProvider serializerSettingsProvider, IMarainWorkflowEngine engineClient) { this.engineClient = engineClient; this.serializerSettingsProvider = serializerSettingsProvider; }
/// <summary> /// Initializes a new instance of the <see cref="BlobStorageWorkflowStore"/> class. /// </summary> /// <param name="workflowContainer">The container in which to store workflows.</param> /// <param name="serializerSettingsProvider">The current <see cref="IJsonSerializerSettingsProvider"/>.</param> public BlobStorageWorkflowStore( BlobContainerClient workflowContainer, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.Container = workflowContainer; this.jsonSerializer = JsonSerializer.Create(serializerSettingsProvider.Instance); }
/// <summary> /// Initializes a new instance of the <see cref="WorkflowEngine"/> class. /// </summary> /// <param name="serializerSettingsProvider">The serializer settings provider for the store.</param> /// <param name="connectionFactory">A factory method to create a sqlconnection for the workflow store.</param> public SqlWorkflowStore( IJsonSerializerSettingsProvider serializerSettingsProvider, Func <ValueTask <SqlConnection> > connectionFactory) { this.serializerSettingsProvider = serializerSettingsProvider; this.connectionFactory = connectionFactory; }
/// <summary> /// Initializes a new instance of the <see cref="ResourceAccessRuleSetStore" /> class /// backed by the given repository. /// </summary> /// <param name="container"> /// The <see cref="BlobContainerClient" /> in which permissions will be stored. /// </param> /// <param name="serializerSettingsProvider">The <see cref="IJsonSerializerSettingsProvider"/> for serializion.</param> public ResourceAccessRuleSetStore( BlobContainerClient container, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.Container = container; this.serializerSettings = serializerSettingsProvider.Instance; }
/// <summary> /// Creates a new instance of the <see cref="EnrollCommand"/> class. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="serializerSettingsProvider"> /// The <see cref="IJsonSerializerSettingsProvider"/> to use when reading manifest files. /// </param> public EnrollCommand( ITenantStore tenantStore, IJsonSerializerSettingsProvider serializerSettingsProvider) : base("enroll", "Enrolls the specified client for the service.") { this.tenantStore = tenantStore; this.serializerSettingsProvider = serializerSettingsProvider; var clientTenantId = new Argument <string>("clientTenantId") { Description = "The Id of the client tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(clientTenantId); var serviceName = new Argument <string>("serviceTenantId") { Description = "The Id of the service tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(serviceName); var configFile = new Option <FileInfo>("--config") { Description = "JSON configuration file to use when enrolling.", }; this.AddOption(configFile); this.Handler = CommandHandler.Create( (string clientTenantId, string serviceTenantId, FileInfo? config) => this.HandleCommand(clientTenantId, serviceTenantId, config)); }
/// <summary> /// Creates a new instance of the <see cref="AddOrUpdateStorageConfigurationCommand"/> class. /// </summary> /// <param name="tenantStore">The tenant store.</param> /// <param name="serializerSettingsProvider"> /// The <see cref="IJsonSerializerSettingsProvider"/> to use when reading manifest files. /// </param> public AddOrUpdateStorageConfigurationCommand( ITenantStore tenantStore, IJsonSerializerSettingsProvider serializerSettingsProvider) : base("add-storage-config", "Adds arbitrary storage configuration for the client.") { this.tenantStore = tenantStore; this.serializerSettingsProvider = serializerSettingsProvider; var tenantId = new Argument <string>("tenantId") { Description = "The Id of the tenant.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(tenantId); var configFile = new Argument <FileInfo>("configFile") { Description = "JSON configuration file path.", Arity = ArgumentArity.ExactlyOne, }; this.AddArgument(configFile); this.Handler = CommandHandler.Create( (string tenantId, FileInfo configFile) => this.HandleCommand(tenantId, configFile)); }
/// <summary> /// Initializes a new instance of the <see cref="TriggerExecutionOrchestrator"/> class. /// </summary> /// <param name="propertyBagFactory">The property bag factory.</param> /// <param name="serializerSettingsProvider">The serialization settings provider.</param> public TriggerExecutionOrchestrator( IPropertyBagFactory propertyBagFactory, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.serializerSettingsProvider = serializerSettingsProvider; this.propertyBagFactory = propertyBagFactory; }
/// <summary> /// Adds services an Azure Blob storage-based implementation of <see cref="ITenantProvider"/>. /// </summary> /// <param name="services">The service collection.</param> /// <param name="getRootTenantStorageConfiguration"> /// A function that returns the <see cref="BlobStorageConfiguration"/> that will be used for the root tenant to /// determine where to store its children. /// </param> /// <returns>The modified service collection.</returns> public static IServiceCollection AddTenantProviderBlobStore( this IServiceCollection services, Func <IServiceProvider, BlobStorageConfiguration> getRootTenantStorageConfiguration) { if (services.Any(s => typeof(ITenantProvider).IsAssignableFrom(s.ServiceType))) { return(services); } services.AddRequiredTenancyServices(); services.AddSingleton(sp => { BlobStorageConfiguration rootTenantStorageConfig = getRootTenantStorageConfiguration(sp); IPropertyBagFactory propertyBagFactory = sp.GetRequiredService <IPropertyBagFactory>(); var rootTenant = new RootTenant(propertyBagFactory); rootTenant.UpdateProperties( values => values.AddBlobStorageConfiguration( TenantProviderBlobStore.ContainerDefinition, rootTenantStorageConfig)); ITenantCloudBlobContainerFactory tenantCloudBlobContainerFactory = sp.GetRequiredService <ITenantCloudBlobContainerFactory>(); IJsonSerializerSettingsProvider serializerSettingsProvider = sp.GetRequiredService <IJsonSerializerSettingsProvider>(); return(new TenantProviderBlobStore(rootTenant, propertyBagFactory, tenantCloudBlobContainerFactory, serializerSettingsProvider)); }); services.AddSingleton <ITenantStore>(sp => sp.GetRequiredService <TenantProviderBlobStore>()); services.AddSingleton <ITenantProvider>(sp => sp.GetRequiredService <TenantProviderBlobStore>()); return(services); }
/// <summary> /// Initializes a new instance of the <see cref="OperationsRepository"/> class. /// </summary> /// <param name="containerFactory">The blob container factory to use to get the container in which operations should be stored.</param> /// <param name="serializerSettingsProvider">The serializer settings factory.</param> public OperationsRepository( IBlobContainerSourceWithTenantLegacyTransition containerFactory, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.containerSource = containerFactory; this.serializerSettings = serializerSettingsProvider.Instance; }
/// <summary> /// Initializes a new instance of the <see cref="BlobContainerPermissionsStoreFactory"/> class. /// </summary> /// <param name="tenantBlobContainerSource"> /// The repository factory. /// </param> /// <param name="serializerSettingsProvider"> /// The <see cref="IJsonSerializerSettingsProvider"/> to use for the stores. /// </param> public BlobContainerPermissionsStoreFactory( IBlobContainerSourceWithTenantLegacyTransition tenantBlobContainerSource, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.tenantBlobContainerSource = tenantBlobContainerSource ?? throw new System.ArgumentNullException(nameof(tenantBlobContainerSource)); this.serializerSettingsProvider = serializerSettingsProvider ?? throw new System.ArgumentNullException(nameof(serializerSettingsProvider)); }
public static void AssertUserNotificationsMatch( UserNotification expected, UserNotification actual, IJsonSerializerSettingsProvider serializerSettingsProvider) { Assert.AreEqual(expected.UserId, actual.UserId); Assert.AreEqual(expected.NotificationType, actual.NotificationType); Assert.AreEqual(expected.Timestamp, actual.Timestamp); Assert.AreEqual(expected.Metadata.CorrelationIds.Length, actual.Metadata.CorrelationIds.Length); for (int idx = 0; idx < expected.Metadata.CorrelationIds.Length; idx++) { Assert.AreEqual(expected.Metadata.CorrelationIds[idx], actual.Metadata.CorrelationIds[idx], $"Correlation Ids at index {idx} do not match."); } Assert.AreEqual(expected.ChannelStatuses.Count(), actual.ChannelStatuses.Count()); foreach (UserNotificationStatus expectedStatus in expected.ChannelStatuses) { UserNotificationStatus?actualStatus = actual.ChannelStatuses.FirstOrDefault(s => s.DeliveryChannelId == expectedStatus.DeliveryChannelId); Assert.IsNotNull(actualStatus, $"Could not find channel delivery status for channel Id '{expectedStatus.DeliveryChannelId}'"); Assert.AreEqual(expectedStatus.DeliveryStatus, actualStatus !.DeliveryStatus, $"Delivery status mismatch for channel Id '{expectedStatus.DeliveryChannelId}'"); Assert.AreEqual(expectedStatus.DeliveryStatusLastUpdated, actualStatus !.DeliveryStatusLastUpdated, $"Delivery status last updated mismatch for channel Id '{expectedStatus.DeliveryChannelId}'"); Assert.AreEqual(expectedStatus.ReadStatus, actualStatus !.ReadStatus, $"Read status mismatch for channel Id '{expectedStatus.DeliveryChannelId}'"); Assert.AreEqual(expectedStatus.ReadStatusLastUpdated, actualStatus !.ReadStatusLastUpdated, $"Read status last updated mismatch for channel Id '{expectedStatus.DeliveryChannelId}'"); } // As always, the easiest way to verify two property bags match is to serialize them. string serializedActualProperties = JsonConvert.SerializeObject(actual.Properties, serializerSettingsProvider.Instance); string serializedExpectedProperties = JsonConvert.SerializeObject(expected.Properties, serializerSettingsProvider.Instance); Assert.AreEqual(serializedExpectedProperties, serializedActualProperties); }
/// <summary> /// Creates a new instance of the external service bindings for a specific http listener. /// </summary> /// <param name="listener">The listener for the external service.</param> /// <param name="serializerSettingsProvider">The serializer settings provider that should be used for the response.</param> public ExternalService(HttpListener listener, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.listener = listener; this.baseUrl = new Uri(this.listener.Prefixes.First()); this.mainLoopTask = Task.Run(() => this.MainLoop(this.cancellationSource.Token)); this.serializerSettingsProvider = serializerSettingsProvider; }
/// <summary> /// Initializes a new instance of the <see cref="GetWorkflowInstanceCountActivity"/> class. /// </summary> /// <param name="workflowEngineFactory">The factory class for the workflow engine.</param> /// <param name="serializerSettingsProvider">The serialization settings provider.</param> /// <param name="client">The client for the workflow engine.</param> public ProcessTriggerActivity( ITenantedWorkflowEngineFactory workflowEngineFactory, IJsonSerializerSettingsProvider serializerSettingsProvider, IMarainWorkflowEngine client) { this.workflowEngineFactory = workflowEngineFactory; this.client = client; this.serializerSettingsProvider = serializerSettingsProvider; }
/// <summary> /// Initializes a new instance of the <see cref="GetWorkflowInstanceCountActivity"/> class. /// </summary> /// <param name="workflowInstanceStoreFactory">The factory class for the workflow instance store.</param> /// <param name="serializerSettingsProvider">The serialization settings provider.</param> /// <param name="tenantProvider">The tenant provider.</param> public GetWorkflowInstanceCountActivity( ITenantedWorkflowInstanceStoreFactory workflowInstanceStoreFactory, IJsonSerializerSettingsProvider serializerSettingsProvider, ITenantProvider tenantProvider) { this.workflowInstanceStoreFactory = workflowInstanceStoreFactory; this.tenantProvider = tenantProvider; this.serializerSettingsProvider = serializerSettingsProvider; }
/// <summary> /// Constructs an instance of <see cref="SaveWorkStateFactory"/>. /// </summary> public SaveWorkStateFactory( IEntityMetadataProvider entityMetadataProvider, IJsonSerializerSettingsProvider jsonSerializerSettingsProvider, INHibernateClassMetadataProvider classMetadataProvider) { _entityMetadataProvider = entityMetadataProvider; _classMetadataProvider = classMetadataProvider; _jsonSerializer = JsonSerializer.Create(jsonSerializerSettingsProvider.GetForSave()); }
/// <summary> /// Initializes a new instance of the <see cref="ClaimPermissionsService"/> class. /// </summary> /// <param name="permissionsStoreFactory">Provides access to the permissions store.</param> /// <param name="marainServicesTenancy">The Marain services tenancy provider.</param> /// <param name="serializerSettingsProvider">The serializer settings provider.</param> public ClaimPermissionsService( IPermissionsStoreFactory permissionsStoreFactory, IMarainServicesTenancy marainServicesTenancy, IJsonSerializerSettingsProvider serializerSettingsProvider) { this.permissionsStoreFactory = permissionsStoreFactory ?? throw new ArgumentNullException(nameof(permissionsStoreFactory)); this.marainServicesTenancy = marainServicesTenancy ?? throw new ArgumentNullException(nameof(marainServicesTenancy)); this.serializerSettingsProvider = serializerSettingsProvider ?? throw new ArgumentNullException(nameof(serializerSettingsProvider)); }
/// <summary> /// Initializes a new instance of the <see cref="TenantedSqlWorkflowInstanceStoreFactory"/> class. /// </summary> /// <param name="serializerSettingsProvider">The JSON serializer settings provider.</param> /// <param name="connectionSource"> /// The <see cref="ISqlConnectionFromDynamicConfiguration"/> that will be used to create /// underlying <see cref="SqlConnection"/> instances for the content stores. /// </param> /// <param name="configurationKey"> /// The tenant properties configuration key in which to find settings. /// </param> public TenantedSqlWorkflowInstanceStoreFactory( IJsonSerializerSettingsProvider serializerSettingsProvider, ISqlConnectionFromDynamicConfiguration connectionSource, string configurationKey) { this.serializerSettingsProvider = serializerSettingsProvider; this.connectionSource = connectionSource; this.configurationKey = configurationKey; }
/// <summary> /// Creates a <see cref="JsonNetPropertyBagFactory"/>. /// </summary> /// <param name="serializerSettingsProvider">Provides serialization settings.</param> public JsonNetPropertyBagFactory(IJsonSerializerSettingsProvider serializerSettingsProvider) { if (serializerSettingsProvider is null) { throw new ArgumentNullException(nameof(serializerSettingsProvider)); } this.serializerSettings = serializerSettingsProvider.Instance; }
/// <summary> /// Create collection /// </summary> /// <param name="db"></param> /// <param name="container"></param> /// <param name="logger"></param> /// <param name="jsonConfig"></param> internal DocumentCollection(DocumentDatabase db, CosmosContainer container, ILogger logger, IJsonSerializerSettingsProvider jsonConfig = null) { Container = container ?? throw new ArgumentNullException(nameof(container)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _db = db ?? throw new ArgumentNullException(nameof(db)); _jsonConfig = jsonConfig; _partitioned = container.PartitionKey.Paths.Any(); }
public void WhenIDeserializeTheJSONBackToAHalDocument() { JObject previouslySerializedHalDocument = this.scenarioContext.Get <JObject>(); IJsonSerializerSettingsProvider serializerSettingsProvider = ContainerBindings.GetServiceProvider(this.scenarioContext).GetRequiredService <IJsonSerializerSettingsProvider>(); var serializer = JsonSerializer.Create(serializerSettingsProvider.Instance); HalDocument result = previouslySerializedHalDocument.ToObject <HalDocument>(serializer); this.scenarioContext.Set(result); }
public void ThenTheResponseShouldContainTheTheWorkflow(string expectedWorkflowName) { Workflow expectedWorkflow = this.scenarioContext.Get <Workflow>(expectedWorkflowName); IJsonSerializerSettingsProvider serializationSettingsProvider = ContainerBindings.GetServiceProvider(this.featureContext).GetRequiredService <IJsonSerializerSettingsProvider>(); string actualWorkflowJson = this.scenarioContext.Get <string>("ResponseBody"); Workflow actualWorkflow = JsonConvert.DeserializeObject <Workflow>(actualWorkflowJson, serializationSettingsProvider.Instance); Assert.AreEqual(expectedWorkflow.Id, actualWorkflow.Id); }
/// <summary> /// Initializes a new instance of the <see cref="ClientTenantProvider"/> class. /// </summary> /// <param name="root">The Root tenant.</param> /// <param name="tenantService">The tenant service.</param> /// <param name="tenantMapper">The tenant mapper to use.</param> /// <param name="jsonSerializerSettingsProvider">The JSON serializer settings provider.</param> public ClientTenantStore( RootTenant root, ITenancyService tenantService, ITenantMapper tenantMapper, IJsonSerializerSettingsProvider jsonSerializerSettingsProvider) : base(root, tenantService, tenantMapper) { this.jsonSerializerSettingsProvider = jsonSerializerSettingsProvider ?? throw new ArgumentNullException(nameof(jsonSerializerSettingsProvider)); }
/// <summary> /// Creates database /// </summary> /// <param name="client"></param> /// <param name="databaseId"></param> /// <param name="databaseThroughput"></param> /// <param name="logger"></param> /// <param name="jsonConfig"></param> internal DocumentDatabase(DocumentClient client, string databaseId, int?databaseThroughput, ILogger logger, IJsonSerializerSettingsProvider jsonConfig = null) { _logger = logger ?? throw new ArgumentNullException(nameof(logger)); Client = client ?? throw new ArgumentNullException(nameof(client)); DatabaseId = databaseId ?? throw new ArgumentNullException(nameof(databaseId)); _jsonConfig = jsonConfig; _collections = new ConcurrentDictionary <string, DocumentCollection>(); _databaseThroughput = databaseThroughput; }
/// <summary> /// Create client /// </summary> /// <param name="config"></param> /// <param name="logger"></param> /// <param name="provider"></param> /// <param name="jsonSettings"></param> public SignalRHubClient(ISignalRClientConfig config, ILogger logger, ITokenProvider provider = null, IJsonSerializerSettingsProvider jsonSettings = null) { _jsonSettings = jsonSettings; _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _provider = provider; _clients = new Dictionary <string, SignalRClientRegistrar>(); _lock = new SemaphoreSlim(1, 1); }
public async Task GivenIHaveCreatedAndStoredANotificationInTheCurrentTransientTenantAndCalledTheResult(string resultName, Table table) { ITenantedUserNotificationStoreFactory storeFactory = this.serviceProvider.GetRequiredService <ITenantedUserNotificationStoreFactory>(); IJsonSerializerSettingsProvider serializerSettingsProvider = this.serviceProvider.GetRequiredService <IJsonSerializerSettingsProvider>(); UserNotification notification = BuildNotificationFrom(table.Rows[0], serializerSettingsProvider.Instance); IUserNotificationStore store = await storeFactory.GetUserNotificationStoreForTenantAsync(this.featureContext.GetTransientTenant()).ConfigureAwait(false); UserNotification result = await store.StoreAsync(notification).ConfigureAwait(false); this.scenarioContext.Set(result, resultName); }
/// <summary> /// Initializes a new instance of the <see cref="CloudEventPublisher"/> class. /// </summary> /// <param name="httpClient">The <see cref="HttpClient"/> to use when POSTing event data to subscribers.</param> /// <param name="serviceIdentityTokenSource">The <see cref="IServiceIdentityAccessTokenSource"/> that will be used to aquire authentication tokens.</param> /// <param name="serializerSettingsProvider">The current <see cref="IJsonSerializerSettingsProvider"/>.</param> /// <param name="logger">The logger.</param> public TenantedCloudEventPublisherFactory( HttpClient httpClient, IServiceIdentityAccessTokenSource serviceIdentityTokenSource, IJsonSerializerSettingsProvider serializerSettingsProvider, ILogger <CloudEventPublisher> logger) { this.httpClient = httpClient; this.serviceIdentityTokenSource = serviceIdentityTokenSource; this.serializerSettingsProvider = serializerSettingsProvider; this.logger = logger; }
/// <summary> /// Creates server /// </summary> /// <param name="config"></param> /// <param name="logger"></param> /// <param name="jsonConfig"></param> public CosmosDbServiceClient(ICosmosDbConfig config, ILogger logger, IJsonSerializerSettingsProvider jsonConfig = null) { _config = config ?? throw new ArgumentNullException(nameof(config)); _logger = logger ?? throw new ArgumentNullException(nameof(logger)); _jsonConfig = jsonConfig; if (string.IsNullOrEmpty(_config?.DbConnectionString)) { throw new ArgumentNullException(nameof(_config.DbConnectionString)); } }
/// <summary> /// Initializes a new instance of the <see cref="MessageIngestionService" /> class. /// </summary> /// <param name="serializerSettingsProvider">Serialization settings provider.</param> /// <param name="propertyBagFactory">Factory to use when creating initial IPropertyBag instances for workflow message envelopes.</param> /// <param name="operationsControl">Allows definition and control of long-running operations.</param> /// <param name="marainServicesTenancy">Marain tenancy services.</param> public MessageIngestionService( IJsonSerializerSettingsProvider serializerSettingsProvider, IPropertyBagFactory propertyBagFactory, IMarainOperationsControl operationsControl, IMarainServicesTenancy marainServicesTenancy) { this.marainServicesTenancy = marainServicesTenancy; this.operationsControl = operationsControl; this.serializerSettingsProvider = serializerSettingsProvider; this.propertyBagFactory = propertyBagFactory; }