コード例 #1
0
 internal Stream(Partition partition, string etag, int version, StreamProperties properties)
 {
     Partition  = partition;
     ETag       = etag;
     Version    = version;
     Properties = properties;
 }
コード例 #2
0
ファイル: Stream.Header.cs プロジェクト: kowalot/Streamstone
 internal Stream(Partition partition, string etag, int version, StreamProperties properties)
 {
     Partition = partition;
     ETag = etag;
     Version = version;
     Properties = properties;
 }
コード例 #3
0
        /// <summary>
        /// Constructs a new <see cref="Stream"/> instance with the given additional properties.
        /// </summary>
        /// <param name="partition">
        /// The partition in which this stream will reside.
        /// </param>
        /// <param name="properties">
        /// The additional properties for this stream.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="partition"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="properties"/> is <c>null</c>
        /// </exception>
        public Stream(Partition partition, StreamProperties properties)
        {
            Requires.NotNull(partition, "partition");
            Requires.NotNull(properties, "properties");

            Partition  = partition;
            Properties = properties;
        }
コード例 #4
0
ファイル: Stream.Header.cs プロジェクト: youscan/Streamstone
        /// <summary>
        /// Constructs a new <see cref="Stream"/> instance with the given additional properties.
        /// </summary>
        /// <param name="partition">
        /// The partition in which this stream will reside.
        /// </param>
        /// <param name="properties">
        /// The additional properties for this stream.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="partition"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="properties"/> is <c>null</c>
        /// </exception>
        public Stream(Partition partition, StreamProperties properties)
        {
            Requires.NotNull(partition, nameof(partition));
            Requires.NotNull(properties, nameof(properties));

            Partition  = partition;
            Properties = properties;
        }
コード例 #5
0
        /// <summary>
        /// Restores a <see cref="Stream"/> instance from particular etag, version and optional properties.
        /// If properties is <c>null</c> the stream header will be merged, otherwise replaced.
        /// </summary>
        /// <param name="partition">
        /// The partition in which a stream resides.
        /// </param>
        /// <param name="etag">
        /// The latest etag
        /// </param>
        /// <param name="version">
        /// The version of the stream corresponding to <paramref name="etag"/>
        /// </param>
        /// <param name="properties">
        /// The additional properties for this stream.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="partition"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="etag"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If <paramref name="etag"/> resolves to an empty <c>string</c>
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If <paramref name="version"/> is less than <c>0</c>
        /// </exception>
        public static Stream From(Partition partition, string etag, int version, StreamProperties properties = null)
        {
            Requires.NotNull(partition, nameof(partition));
            Requires.NotNullOrEmpty(etag, nameof(etag));
            Requires.GreaterThanOrEqualToZero(version, nameof(version));

            return(new Stream(partition, etag, version, properties ?? StreamProperties.None));
        }
コード例 #6
0
ファイル: Stream.Header.cs プロジェクト: kowalot/Streamstone
        /// <summary>
        /// Constructs a new <see cref="Stream"/> instance with the given additional properties.
        /// </summary>
        /// <param name="partition">
        /// The partition in which this stream will reside. 
        /// </param>
        /// <param name="properties">
        /// The additional properties for this stream.
        /// </param>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="partition"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="properties"/> is <c>null</c>
        /// </exception>
        public Stream(Partition partition, StreamProperties properties)
        {
            Requires.NotNull(partition, "partition");
            Requires.NotNull(properties, "properties");

            Partition = partition;
            Properties = properties;
        }
コード例 #7
0
 public StreamEntity(Partition partition, string etag, int version, StreamProperties properties)
 {
     Partition    = partition;
     PartitionKey = partition.PartitionKey;
     RowKey       = partition.StreamRowKey();
     ETag         = etag;
     Version      = version;
     Properties   = properties;
 }
コード例 #8
0
ファイル: Stream.Api.cs プロジェクト: usaukel/Streamstone
        /// <summary>
        /// Initiates an asynchronous operation that sets the given stream properties (metadata).
        /// </summary>
        /// <param name="stream">The stream header.</param>
        /// <param name="properties">The properties.</param>
        /// <returns>The promise, that wil eventually return updated stream header or will fail with exception</returns>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="stream"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="properties"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If given stream header represents a transient stream
        /// </exception>
        /// <exception cref="ConcurrencyConflictException">
        ///     If stream has been changed in storage after the given stream header has been read
        /// </exception>
        public static Task <Stream> SetPropertiesAsync(Stream stream, StreamProperties properties)
        {
            Requires.NotNull(stream, nameof(stream));
            Requires.NotNull(properties, nameof(properties));

            if (stream.IsTransient)
            {
                throw new ArgumentException("Can't set properties on transient stream", "stream");
            }

            return(new SetPropertiesOperation(stream, properties).ExecuteAsync());
        }
コード例 #9
0
 public static StreamEntity From(DynamicTableEntity entity)
 {
     return(new StreamEntity
     {
         PartitionKey = entity.PartitionKey,
         RowKey = entity.RowKey,
         ETag = entity.ETag,
         Timestamp = entity.Timestamp,
         Version = (int)entity.Properties["Version"].PropertyAsObject,
         Properties = StreamProperties.From(entity)
     });
 }
コード例 #10
0
        /// <summary>
        /// Sets the given stream properties (metadata).
        /// </summary>
        /// <param name="stream">The stream header.</param>
        /// <param name="properties">The properties.</param>
        /// <returns>Updated stream header</returns>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="stream"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentNullException">
        ///     If <paramref name="properties"/> is <c>null</c>
        /// </exception>
        /// <exception cref="ArgumentException">
        ///     If given stream header represents a transient stream
        /// </exception>
        /// <exception cref="ConcurrencyConflictException">
        ///     If stream has been changed in storage after the given stream header has been read
        /// </exception>
        public static Stream SetProperties(Stream stream, StreamProperties properties)
        {
            Requires.NotNull(stream, "stream");
            Requires.NotNull(properties, "properties");

            if (stream.IsTransient)
            {
                throw new ArgumentException("Can't set properties on transient stream", "stream");
            }

            return(new SetPropertiesOperation(stream, properties).Execute());
        }
コード例 #11
0
ファイル: Stream.Api.cs プロジェクト: usaukel/Streamstone
 /// <summary>
 /// Initiates an asynchronous operation that provisions new stream with the given properties in the specified partition.
 /// </summary>
 /// <param name="partition">The partition.</param>
 /// <param name="properties">The stream properties</param>
 /// <returns>The promise, that wil eventually return stream header or will fail with exception</returns>
 /// <exception cref="ArgumentNullException">
 ///     If <paramref name="partition"/> is <c>null</c>
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     If <paramref name="properties"/> is <c>null</c>
 /// </exception>
 /// <exception cref="ConcurrencyConflictException">
 /// If stream already exists in the partition
 /// </exception>
 public static Task <Stream> ProvisionAsync(Partition partition, StreamProperties properties)
 {
     return(ProvisionAsync(new Stream(partition, properties)));
 }
コード例 #12
0
 public override void ReadEntity(IDictionary <string, EntityProperty> properties, OperationContext operationContext)
 {
     base.ReadEntity(properties, operationContext);
     Properties = StreamProperties.ReadEntity(properties);
 }
コード例 #13
0
 /// <summary>
 /// Provisions new stream  with the given properties in the specified partition.
 /// </summary>
 /// <param name="partition">The partition.</param>
 /// <param name="properties">The stream properties</param>
 /// <returns>The stream header</returns>
 /// <exception cref="ArgumentNullException">
 ///     If <paramref name="partition"/> is <c>null</c>
 /// </exception>
 /// <exception cref="ArgumentNullException">
 ///     If <paramref name="properties"/> is <c>null</c>
 /// </exception>
 /// <exception cref="ConcurrencyConflictException">
 /// If stream already exists in the partition
 /// </exception>
 public static Stream Provision(Partition partition, StreamProperties properties)
 {
     return(Provision(new Stream(partition, properties)));
 }
コード例 #14
0
 public Replace(Stream stream, StreamProperties properties)
 {
     this.stream            = stream.Entity();
     this.stream.Properties = properties;
     partition = stream.Partition;
 }
コード例 #15
0
 public SetPropertiesOperation(Stream stream, StreamProperties properties)
 {
     this.stream     = stream;
     this.properties = properties;
     table           = stream.Partition.Table;
 }