/// <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;
        }
Пример #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IdentifiedSerializerRepresentation"/> class.
        /// </summary>
        /// <param name="id">The serializer representation identifier.</param>
        /// <param name="serializerRepresentation">The serializer description.</param>
        /// <param name="serializationFormat">The serialization format.</param>
        public IdentifiedSerializerRepresentation(
            int id,
            SerializerRepresentation serializerRepresentation,
            SerializationFormat serializationFormat)
        {
            serializerRepresentation.MustForArg(nameof(serializerRepresentation)).NotBeNull();
            serializationFormat.MustForArg(nameof(serializationFormat)).NotBeEqualTo(SerializationFormat.Invalid);

            this.Id = id;
            this.SerializerRepresentation = serializerRepresentation;
            this.SerializationFormat      = serializationFormat;
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="GetOrAddIdentifiedSerializerRepresentationOp"/> class.
        /// </summary>
        /// <param name="specifiedResourceLocator">The stream locator to inspect.</param>
        /// <param name="serializerRepresentation">The serializer representation.</param>
        /// <param name="serializationFormat">The serialization format.</param>
        public GetOrAddIdentifiedSerializerRepresentationOp(
            IResourceLocator specifiedResourceLocator,
            SerializerRepresentation serializerRepresentation,
            SerializationFormat serializationFormat)
        {
            specifiedResourceLocator.MustForArg(nameof(specifiedResourceLocator)).NotBeNull();
            serializerRepresentation.MustForArg(nameof(serializerRepresentation)).NotBeNull();
            serializationFormat.MustForArg(nameof(serializationFormat)).NotBeEqualTo(SerializationFormat.Invalid);

            this.SpecifiedResourceLocator = specifiedResourceLocator;
            this.SerializerRepresentation = serializerRepresentation;
            this.SerializationFormat      = serializationFormat;
        }
Пример #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="SqlStream"/> class.
        /// </summary>
        /// <param name="name">The name of the stream.</param>
        /// <param name="defaultConnectionTimeout">The default connection timeout.</param>
        /// <param name="defaultCommandTimeout">The default command timeout.</param>
        /// <param name="defaultSerializerRepresentation">Default serializer description to use.</param>
        /// <param name="defaultSerializationFormat">Default serializer format.</param>
        /// <param name="serializerFactory">The factory to get a serializer to use for objects.</param>
        /// <param name="resourceLocatorProtocol">The protocols for getting locators.</param>
        public SqlStream(
            string name,
            TimeSpan defaultConnectionTimeout,
            TimeSpan defaultCommandTimeout,
            SerializerRepresentation defaultSerializerRepresentation,
            SerializationFormat defaultSerializationFormat,
            ISerializerFactory serializerFactory,
            IResourceLocatorProtocols resourceLocatorProtocol)
            : base(name, serializerFactory, defaultSerializerRepresentation, defaultSerializationFormat, resourceLocatorProtocol)
        {
            name.MustForArg(nameof(name)).NotBeNullNorWhiteSpace();
            defaultSerializerRepresentation.MustForArg(nameof(defaultSerializerRepresentation)).NotBeNull();
            serializerFactory.MustForArg(nameof(serializerFactory)).NotBeNull();
            resourceLocatorProtocol.MustForArg(nameof(resourceLocatorProtocol)).NotBeNull();

            this.StreamRepresentation     = new StreamRepresentation(this.Name);
            this.DefaultConnectionTimeout = defaultConnectionTimeout;
            this.DefaultCommandTimeout    = defaultCommandTimeout;

            var allLocators = this.ResourceLocatorProtocols.Execute(new GetAllResourceLocatorsOp());

            this.singleLocator = allLocators.Count == 1 ? allLocators.Single().ConfirmAndConvert <SqlServerLocator>() : null;
        }