AgainstNullAndEmpty() private method

private AgainstNullAndEmpty ( [ argumentName, [ value ) : void
argumentName [
value [
return void
        /// <summary>
        /// Specifies the path and file name for the instance mapping XML. The default is <code>instance-mapping.xml</code>.
        /// </summary>
        /// <param name="filePath">The relative or absolute file path to the instance mapping XML file.</param>
        public InstanceMappingFileSettings FilePath(string filePath)
        {
            Guard.AgainstNullAndEmpty(nameof(filePath), filePath);

            this.GetSettings().Set(InstanceMappingFileFeature.FilePathSettingsKey, filePath);
            return(this);
        }
        /// <summary>
        /// The site key to use, this goes hand in hand with Bus.SendToSites(key, message).
        /// </summary>
        /// <param name="siteKey"></param>
        /// <param name="address">The channel address.</param>
        /// <param name="type">The channel type. Default is `http`.</param>
        /// <param name="legacyMode">Pass `true` to set the forwarding mode for this site to legacy mode.</param>
        public void AddSite(string siteKey, string address, string type = "http", bool legacyMode = false)
        {
            Guard.AgainstNullAndEmpty(nameof(siteKey), siteKey);
            Guard.AgainstNullAndEmpty(nameof(address), address);
            Guard.AgainstNullAndEmpty(nameof(type), type);

            var site = new Site
            {
                Channel = new Channel
                {
                    Address = address,
                    Type    = type
                },
                Key        = siteKey,
                LegacyMode = legacyMode
            };

            if (settings.TryGet(out List <Site> sites))
            {
                sites.Add(site);
            }

            settings.Set <List <Site> >(new List <Site>
            {
                site
            });
        }
        /// <summary>
        /// Configures the location where message files are stored.
        /// </summary>
        /// <param name="transportExtensions">The transport extensions to extend.</param>
        /// <param name="path">The storage path.</param>
        public static void StorageDirectory(this TransportExtensions <AcceptanceTestTransport> transportExtensions, string path)
        {
            Guard.AgainstNullAndEmpty(nameof(path), path);
            Guard.AgainstNull(nameof(transportExtensions), transportExtensions);
            PathChecker.ThrowForBadPath(path, "StorageDirectory");

            transportExtensions.GetSettings().Set(AcceptanceTestTransportInfrastructure.StorageLocationKey, path);
        }
Example #4
0
        /// <summary>
        /// Specifies a string value that will be prepended to the name of every SQS queue
        /// referenced by the endpoint. This is useful when deploying many environments of the
        /// same application in the same AWS region (say, a development environment, a QA environment
        /// and a production environment), and you need to differentiate the queue names per environment.
        /// </summary>
        public static TransportExtensions <SqsTransport> QueueNamePrefix(this TransportExtensions <SqsTransport> transportExtensions, string queueNamePrefix)
        {
            Guard.AgainstNull(nameof(transportExtensions), transportExtensions);
            Guard.AgainstNullAndEmpty(nameof(queueNamePrefix), queueNamePrefix);
            transportExtensions.GetSettings().Set(SettingsKeys.QueueNamePrefix, queueNamePrefix);

            return(transportExtensions);
        }
        /// <summary>
        /// Adds a section to the startup diagnostics.
        /// </summary>
        public static void AddStartupDiagnosticsSection(this ReadOnlySettings settings, string sectionName, object section)
        {
            Guard.AgainstNull(nameof(settings), settings);
            Guard.AgainstNullAndEmpty(nameof(sectionName), sectionName);
            Guard.AgainstNull(nameof(section), section);

            settings.Get <StartupDiagnosticEntries>().Add(sectionName, section);
        }
        /// <summary>
        /// Override the default database used by the persistence
        /// </summary>
        public static PersistenceExtensions <MongoPersistence> DatabaseName(this PersistenceExtensions <MongoPersistence> persistenceExtensions, string databaseName)
        {
            Guard.AgainstNull(nameof(persistenceExtensions), persistenceExtensions);
            Guard.AgainstNullAndEmpty(nameof(databaseName), databaseName);

            persistenceExtensions.GetSettings().Set(SettingsKeys.DatabaseName, databaseName);
            return(persistenceExtensions);
        }
 /// <summary>
 /// Configures the database schema to be used.
 /// </summary>
 public static void Schema(this PersistenceExtensions <SqlPersistence> configuration, string schema)
 {
     Guard.AgainstNull(nameof(configuration), configuration);
     Guard.AgainstNullAndEmpty(nameof(schema), schema);
     Guard.AgainstSqlDelimiters(nameof(schema), schema);
     configuration.GetSettings()
     .Set("SqlPersistence.Schema", schema);
 }
        /// <summary>
        /// Sets the location to which to write/read serialized properties for the databus.
        /// </summary>
        /// <param name="config">The configuration object.</param>
        /// <param name="basePath">The location to which to write/read serialized properties for the databus.</param>
        /// <returns>The configuration.</returns>
        public static DataBusExtensions <FileShareDataBus> BasePath(this DataBusExtensions <FileShareDataBus> config, string basePath)
        {
            Guard.AgainstNull(nameof(config), config);
            Guard.AgainstNullAndEmpty(nameof(basePath), basePath);
            config.Settings.Set("FileShareDataBusPath", basePath);

            return(config);
        }
Example #9
0
        /// <summary>
        /// In this mode, a host id will be generated from <paramref name="instanceName" /> and <paramref name="hostName" />.
        /// </summary>
        /// <remarks>
        /// This mode is recommended when deploying in Azure roles or <see cref="UsingInstalledFilePath" /> is not appropriate.
        /// </remarks>
        public HostInfoSettings UsingNames(string instanceName, string hostName)
        {
            Guard.AgainstNullAndEmpty(nameof(instanceName), instanceName);
            Guard.AgainstNullAndEmpty(nameof(hostName), hostName);

            config.Settings.Set(HostInformationFeature.HostIdSettingsKey, DeterministicGuid.Create(instanceName, hostName));
            return(this);
        }
Example #10
0
 public AuditContext(OutgoingMessage message, string auditAddress, IBehaviorContext parent)
     : base(parent)
 {
     Guard.AgainstNull(nameof(message), message);
     Guard.AgainstNullAndEmpty(nameof(auditAddress), auditAddress);
     Message      = message;
     AuditAddress = auditAddress;
 }
Example #11
0
        /// <summary>
        /// In this mode, a host id will be generated from <paramref name="instanceName" /> and <paramref name="hostName" />.
        /// </summary>
        /// <remarks>
        /// This mode is recommended when deploying in Azure roles or <see cref="UsingInstalledFilePath" /> is not appropriate.
        /// </remarks>
        public HostInfoSettings UsingNames(string instanceName, string hostName)
        {
            Guard.AgainstNullAndEmpty(nameof(instanceName), instanceName);
            Guard.AgainstNullAndEmpty(nameof(hostName), hostName);

            config.Settings.Get <HostingComponent.Settings>().HostId = DeterministicGuid.Create(instanceName, hostName);
            return(this);
        }
        /// <summary>
        /// Creates a <see cref="IRoutingContext" /> based on the current context.
        /// </summary>
        public static IRoutingContext CreateRoutingContext(this ForkConnector <ITransportReceiveContext, IRoutingContext> forkConnector, OutgoingMessage outgoingMessage, string localAddress, ITransportReceiveContext sourceContext)
        {
            Guard.AgainstNull(nameof(outgoingMessage), outgoingMessage);
            Guard.AgainstNullAndEmpty(nameof(localAddress), localAddress);
            Guard.AgainstNull(nameof(sourceContext), sourceContext);

            return(new RoutingContext(outgoingMessage, new UnicastRoutingStrategy(localAddress), sourceContext));
        }
Example #13
0
        /// <summary>
        /// Adds a static unicast route for a given message type.
        /// </summary>
        /// <param name="messageType">The message which should be routed.</param>
        /// <param name="destination">The destination endpoint.</param>
        public void RouteToEndpoint(Type messageType, string destination)
        {
            Guard.AgainstNull(nameof(messageType), messageType);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);
            ThrowOnAddress(destination);

            Settings.GetOrCreate <ConfiguredUnicastRoutes>().Add(new TypeRouteSource(messageType, UnicastRoute.CreateFromEndpointName(destination)));
        }
        /// <summary>
        /// Overrides the default topic name used to publish events between endpoints.
        /// </summary>
        /// <param name="transportExtensions"></param>
        /// <param name="topicName">The name of the topic used to publish events between endpoints.</param>
        public static TransportExtensions <AzureServiceBusTransport> TopicName(this TransportExtensions <AzureServiceBusTransport> transportExtensions, string topicName)
        {
            Guard.AgainstNullAndEmpty(nameof(topicName), topicName);

            transportExtensions.GetSettings().Set(SettingsKeys.TopicName, topicName);

            return(transportExtensions);
        }
Example #15
0
        /// <summary>
        /// Adds a section to the startup diagnostics.
        /// </summary>
        public static void AddStartupDiagnosticsSection(this ReadOnlySettings settings, string sectionName, object section)
        {
            Guard.AgainstNull(nameof(settings), settings);
            Guard.AgainstNullAndEmpty(nameof(sectionName), sectionName);
            Guard.AgainstNull(nameof(section), section);

            settings.Get <HostingComponent.Configuration>().StartupDiagnostics.Add(sectionName, section);
        }
Example #16
0
        /// <summary>
        /// Creates a new fault configuration.
        /// </summary>
        /// <param name="errorQueue">The address of the error queue.</param>
        /// <param name="unrecoverableExceptionTypes">Exception types that will be treated as unrecoverable.</param>
        public FailedConfig(string errorQueue, HashSet <Type> unrecoverableExceptionTypes)
        {
            Guard.AgainstNullAndEmpty(nameof(errorQueue), errorQueue);
            Guard.AgainstNull(nameof(unrecoverableExceptionTypes), unrecoverableExceptionTypes);

            ErrorQueue = errorQueue;
            UnrecoverableExceptionTypes = unrecoverableExceptionTypes;
        }
        /// <summary>
        /// Registers a publisher endpoint for all event types in a given assembly.
        /// </summary>
        /// <param name="routingSettings">The <see cref="RoutingSettings&lt;T&gt;" /> to extend.</param>
        /// <param name="assembly">The assembly containing the event types.</param>
        /// <param name="publisherEndpoint">The publisher endpoint.</param>
        public static void RegisterPublisher <T>(this RoutingSettings <T> routingSettings, Assembly assembly, string publisherEndpoint) where T : TransportDefinition, IMessageDrivenSubscriptionTransport
        {
            Guard.AgainstNull(nameof(assembly), assembly);
            Guard.AgainstNullAndEmpty(nameof(publisherEndpoint), publisherEndpoint);

            ThrowOnAddress(publisherEndpoint);

            routingSettings.Settings.GetOrCreate <ConfiguredPublishers>().Add(new AssemblyPublisherSource(assembly, PublisherAddress.CreateFromEndpointName(publisherEndpoint)));
        }
 public void Set(string newTimeoutManagerAddress)
 {
     Guard.AgainstNullAndEmpty(newTimeoutManagerAddress, "newTimeoutManagerAddress");
     if (TransportAddress != null)
     {
         throw new InvalidOperationException("Another feature or the UnicastBusConfig section has already set the timeout manager address.");
     }
     TransportAddress = newTimeoutManagerAddress;
 }
 /// <summary>
 /// Creates a new instance of <see cref="AzureServiceBusTransport"/>.
 /// </summary>
 public AzureServiceBusTransport(string connectionString) : base(
         defaultTransactionMode: TransportTransactionMode.SendsAtomicWithReceive,
         supportsDelayedDelivery: true,
         supportsPublishSubscribe: true,
         supportsTTBR: true)
 {
     Guard.AgainstNullAndEmpty(nameof(connectionString), connectionString);
     ConnectionString = connectionString;
 }
        /// <summary>
        /// Creates a new instance of an AccountInfo.
        /// </summary>
        public AccountInfo(string alias, string connectionString)
        {
            Guard.AgainstNull(nameof(alias), alias);
            Guard.AgainstNullAndEmpty(nameof(connectionString), connectionString);

            Alias               = alias;
            Connection          = new ConnectionString(connectionString);
            RegisteredEndpoints = new HashSet <string>(StringComparer.OrdinalIgnoreCase);
        }
Example #21
0
        public static TransportExtensions <RabbitMQTransport> SetClientCertificate(this TransportExtensions <RabbitMQTransport> transportExtensions, string path, string password)
        {
            Guard.AgainstNull(nameof(transportExtensions), transportExtensions);
            Guard.AgainstNullAndEmpty(nameof(path), path);
            Guard.AgainstNullAndEmpty(nameof(password), password);

            transportExtensions.Transport.ClientCertificate = new X509Certificate2(path, password);
            return(transportExtensions);
        }
        /// <summary>
        /// Registers a publisher endpoint for all event types in a given assembly.
        /// </summary>
        /// <param name="assembly">The assembly containing the event types.</param>
        /// <param name="publisherEndpoint">The publisher endpoint.</param>
        public void RegisterPublisher(Assembly assembly, string publisherEndpoint)
        {
            Guard.AgainstNull(nameof(assembly), assembly);
            Guard.AgainstNullAndEmpty(nameof(publisherEndpoint), publisherEndpoint);

            ThrowOnAddress(publisherEndpoint);

            Settings.GetOrCreate <ConfiguredPublishers>().Add(new AssemblyPublisherSource(assembly, PublisherAddress.CreateFromEndpointName(publisherEndpoint)));
        }
Example #23
0
        /// <summary>
        /// Configures a custom path where host diagnostics is written.
        /// </summary>
        /// <param name="config">Configuration object to extend.</param>
        /// <param name="path">The custom path to use.</param>
        public static void SetDiagnosticsPath(this EndpointConfiguration config, string path)
        {
            Guard.AgainstNull(nameof(config), config);
            Guard.AgainstNullAndEmpty(nameof(path), path);

            PathChecker.ThrowForBadPath(path, "Diagnostics root path");

            config.GetSettings().Get <HostingComponent.Configuration>().DiagnosticsPath = path;
        }
Example #24
0
        public static TransportExtensions <AzureServiceBusTransport> ConnectionString(this TransportExtensions <AzureServiceBusTransport> transportExtensions, Func <string> connectionString)
        {
            Guard.AgainstNull(nameof(connectionString), connectionString);
            var value = connectionString();

            Guard.AgainstNullAndEmpty(nameof(connectionString), value);
            transportExtensions.Transport.ConnectionString = value;
            return(transportExtensions);
        }
        /// <summary>
        /// Sets a default schema for both input and output queues
        /// </summary>
        public static TransportExtensions <SqlServerTransport> DefaultSchema(this TransportExtensions <SqlServerTransport> transportExtensions, string schemaName)
        {
            Guard.AgainstNull(nameof(transportExtensions), transportExtensions);
            Guard.AgainstNullAndEmpty(nameof(schemaName), schemaName);

            transportExtensions.GetSettings().Set(SettingsKeys.DefaultSchemaSettingsKey, schemaName);

            return(transportExtensions);
        }
 /// <summary>
 /// Initializes a new instance of <see cref="CriticalErrorContext" />.
 /// </summary>
 /// <param name="stop">See <see cref="ICriticalErrorContext.Stop" />.</param>
 /// <param name="error">See <see cref="ICriticalErrorContext.Error" />.</param>
 /// <param name="exception">See <see cref="ICriticalErrorContext.Exception" />.</param>
 public CriticalErrorContext(Func <CancellationToken, Task> stop, string error, Exception exception)
 {
     Guard.AgainstNull(nameof(stop), stop);
     Guard.AgainstNullAndEmpty(nameof(error), error);
     Guard.AgainstNull(nameof(exception), exception);
     Stop      = stop;
     Error     = error;
     Exception = exception;
 }
Example #27
0
        /// <summary>
        /// Adds a static unicast route for all types contained in the specified assembly.
        /// </summary>
        /// <param name="assembly">The assembly whose messages should be routed.</param>
        /// <param name="destination">Destination endpoint.</param>
        public void RouteToEndpoint(Assembly assembly, string destination)
        {
            Guard.AgainstNull(nameof(assembly), assembly);
            Guard.AgainstNullAndEmpty(nameof(destination), destination);

            ThrowOnAddress(destination);

            Settings.GetOrCreate <ConfiguredUnicastRoutes>().Add(new AssemblyRouteSource(assembly, UnicastRoute.CreateFromEndpointName(destination)));
        }
Example #28
0
        /// <summary>
        /// Specifies the certificate to use for client authentication when connecting to the broker via TLS.
        /// </summary>
        /// <param name="transportExtensions">The transport configuration object</param>
        /// <param name="path">The path to the certificate file.</param>
        /// <param name="password">The password for the certificate specified in <paramref name="path"/>.</param>
        public static TransportExtensions <RabbitMQTransport> SetClientCertificate(this TransportExtensions <RabbitMQTransport> transportExtensions, string path, string password)
        {
            Guard.AgainstNull(nameof(transportExtensions), transportExtensions);
            Guard.AgainstNullAndEmpty(nameof(path), path);
            Guard.AgainstNullAndEmpty(nameof(password), password);

            transportExtensions.GetSettings().Set(SettingsKeys.ClientCertificateCollection, new X509Certificate2Collection(new X509Certificate2(path, password)));

            return(transportExtensions);
        }
        /// <summary>
        /// Creates a <see cref="IForwardingContext" /> based on the current context.
        /// </summary>
        public static IForwardingContext CreateForwardingContext(this ForkConnector <IIncomingPhysicalMessageContext, IForwardingContext> forwardingContext, OutgoingMessage message, string forwardingAddress, IIncomingPhysicalMessageContext sourceContext)
        {
            Guard.AgainstNull(nameof(message), message);
            Guard.AgainstNullAndEmpty(nameof(forwardingAddress), forwardingAddress);
            Guard.AgainstNull(nameof(sourceContext), sourceContext);

            var connector = (IForkConnector <IIncomingPhysicalMessageContext, IIncomingPhysicalMessageContext, IForwardingContext>)forwardingContext;

            return(connector.CreateForwardingContext(message, forwardingAddress, sourceContext));
        }
Example #30
0
        /// <summary>Override the default table name used for storing delayed messages.</summary>
        /// <param name="delayedMessagesTableName">New table name.</param>
        public void UseTableName(string delayedMessagesTableName)
        {
            Guard.AgainstNullAndEmpty(nameof(delayedMessagesTableName), delayedMessagesTableName);

            if (tableNameRegex.IsMatch(delayedMessagesTableName) == false)
            {
                throw new ArgumentException($"{nameof(delayedMessagesTableName)} must match the following regular expression '{tableNameRegex}'");
            }

            this.GetSettings().Set(WellKnownConfigurationKeys.DelayedDelivery.TableName, delayedMessagesTableName.ToLower());
        }