/// <summary> /// Initializes a new instance of the <see cref="SqlServerStreamConfig"/> class. /// </summary> /// <param name="name">Name of the stream.</param> /// <param name="accessKinds">Access the stream has.</param> /// <param name="defaultConnectionTimeout">Default timeout to use when connecting to SQL Server.</param> /// <param name="defaultCommandTimeout">Default timeout to use when running a command on SQL Server.</param> /// <param name="defaultSerializerRepresentation">Default <see cref="SerializerRepresentation"/> to use (used for identifier serialization).</param> /// <param name="defaultSerializationFormat">Default <see cref="SerializationFormat"/> to use.</param> /// <param name="allLocators">All <see cref="ISqlServerLocator"/>'s.</param> public SqlServerStreamConfig( string name, StreamAccessKinds accessKinds, TimeSpan defaultConnectionTimeout, TimeSpan defaultCommandTimeout, SerializerRepresentation defaultSerializerRepresentation, SerializationFormat defaultSerializationFormat, IReadOnlyCollection <ISqlServerLocator> allLocators) { name.MustForArg(nameof(name)).NotBeNullNorWhiteSpace(); accessKinds.MustForArg(nameof(accessKinds)).NotBeEqualTo(StreamAccessKinds.None); defaultConnectionTimeout.TotalMilliseconds.MustForArg(Invariant($"{nameof(defaultConnectionTimeout)}.{nameof(TimeSpan.TotalMilliseconds)}")).BeGreaterThanOrEqualTo(0d); defaultCommandTimeout.TotalMilliseconds.MustForArg(Invariant($"{nameof(defaultCommandTimeout)}.{nameof(TimeSpan.TotalMilliseconds)}")).BeGreaterThanOrEqualTo(0d); defaultSerializerRepresentation.MustForArg(nameof(defaultSerializerRepresentation)).NotBeNull(); defaultSerializationFormat.MustForArg(nameof(defaultSerializationFormat)).NotBeEqualTo(SerializationFormat.Invalid); allLocators.MustForArg(nameof(allLocators)).NotBeNullNorEmptyEnumerableNorContainAnyNulls(); this.Name = name; this.AccessKinds = accessKinds; this.DefaultConnectionTimeout = defaultConnectionTimeout; this.DefaultCommandTimeout = defaultCommandTimeout; this.DefaultSerializerRepresentation = defaultSerializerRepresentation; this.DefaultSerializationFormat = defaultSerializationFormat; this.AllLocators = allLocators; }
/// <summary> /// Initializes a new instance of the <see cref="CreateStreamUserOp"/> class. /// </summary> /// <param name="loginName">The login name of the user.</param> /// <param name="userName">The username of the user.</param> /// <param name="clearTextPassword">The clear text password.</param> /// <param name="streamAccessKinds"><see cref="Database.Domain.StreamAccessKinds"/> to grant access for.</param> /// <param name="shouldCreateLogin">A value indicating whether or not to create the login or look it up.</param> public CreateStreamUserOp( string loginName, string userName, string clearTextPassword, StreamAccessKinds streamAccessKinds, bool shouldCreateLogin) { userName.MustForArg(nameof(userName)).NotBeNullNorWhiteSpace().And().BeAlphanumeric(new[] { '-' }); streamAccessKinds.MustForArg(nameof(streamAccessKinds)).NotBeEqualTo(Database.Domain.StreamAccessKinds.None); if (shouldCreateLogin) { clearTextPassword.MustForArg(nameof(clearTextPassword)).NotBeNullNorWhiteSpace(); } else { loginName.MustForArg(nameof(loginName)).NotBeNullNorWhiteSpace(); } if (!string.IsNullOrWhiteSpace(loginName)) { loginName.MustForArg(nameof(loginName)).BeAlphanumeric(new[] { '-' }); } var individualStreamAccessKinds = streamAccessKinds.GetIndividualFlags <StreamAccessKinds>(); if (individualStreamAccessKinds.Except(CreateStreamUserOp.SupportedStreamAccessKinds).Any()) { var supportedValuesString = SupportedStreamAccessKinds.Select(_ => _.ToString()).ToDelimitedString(","); var providedValuesString = individualStreamAccessKinds.Select(_ => _.ToString()).ToDelimitedString(","); throw new ArgumentException(Invariant($"Unsupported access type provided; supported: '{supportedValuesString}', provided: '{providedValuesString}'."), nameof(streamAccessKinds)); } this.LoginName = loginName; this.UserName = userName; this.ClearTextPassword = clearTextPassword; this.StreamAccessKinds = streamAccessKinds; this.ShouldCreateLogin = shouldCreateLogin; }