Beispiel #1
0
        /// <summary>
        /// Writes the channel synchronously
        /// </summary>
        /// <param name="self">The channel to write.</param>
        /// <param name="value">The value to write.</param>
        /// <param name="timeout">The write timeout.</param>
        /// <param name="offer">The two-phase offer instance or null.</param>
        public static void Write(this IUntypedChannel self, object value, TimeSpan timeout, ITwoPhaseOffer offer = null)
        {
            var res = WriteAsync(self, value, timeout, offer).WaitForTask();

            if (res.Exception != null)
            {
                if (res.Exception is AggregateException && ((AggregateException)res.Exception).Flatten().InnerExceptions.Count == 1)
                {
                    throw ((AggregateException)res.Exception).InnerException;
                }

                throw res.Exception;
            }
            else if (res.IsCanceled)
            {
                throw new OperationCanceledException();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Writes the channel synchronously
        /// </summary>
        /// <param name="self">The channel to write.</param>
        /// <param name="value">The value to write.</param>
        /// <param name="offer">The two-phase offer.</param>
        public static void Write(this IUntypedChannel self, object value, ITwoPhaseOffer offer)
        {
            var res = WriteAsync(self, value, offer).WaitForTask();

            if (res.Exception != null)
            {
                if (res.Exception.Flatten().InnerExceptions.Count == 1)
                {
                    throw res.Exception.InnerException;
                }

                throw res.Exception;
            }
            else if (res.IsCanceled)
            {
                throw new OperationCanceledException();
            }
        }
Beispiel #3
0
 /// <summary>
 /// Reads the channel asynchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="offer">The two-phase offer.</param>
 /// <param name="timeout">The read timeout.</param>
 public static object Read(this IUntypedChannel self, TimeSpan timeout, ITwoPhaseOffer offer = null)
 {
     return(WaitForTask <object>(ReadAsync(self, timeout, offer)).Result);
 }
Beispiel #4
0
 /// <summary>
 /// Creates a read request for the given channel.
 /// </summary>
 /// <param name="self">The channel to request the read from.</param>
 /// <returns>The created request</returns>
 public static IMultisetRequestUntyped RequestRead(this IUntypedChannel self)
 {
     return(UntypedAccessMethods.CreateReadAccessor(self).RequestRead(self));
 }
Beispiel #5
0
 /// <summary>
 /// Writes the channel asynchronously
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 public static Task WriteAsync(this IUntypedChannel self, object value)
 {
     return(WriteAsync(self, value, null));
 }
Beispiel #6
0
 /// <summary>
 /// Writes the channel synchronously
 /// </summary>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="timeout">The write timeout.</param>
 /// <param name="cancelToken">The cancellation token.</param>
 public static void Write(this IUntypedChannel self, object value, TimeSpan timeout, CancellationToken cancelToken)
 {
     Write(self, value, new TimeoutOffer(timeout, cancelToken));
 }
Beispiel #7
0
 /// <summary>
 /// Writes the channel synchronously
 /// </summary>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="timeout">The write timeout.</param>
 public static void Write(this IUntypedChannel self, object value, TimeSpan timeout)
 {
     Write(self, value, new TimeoutOffer(timeout));
 }
Beispiel #8
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="offer">The two-phase offer token.</param>
 public static object Read(this IUntypedChannel self, ITwoPhaseOffer offer)
 {
     return(WaitForTask <object>(ReadAsync(self, offer)).Result);
 }
Beispiel #9
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="cancelToken">The cancellation token.</param>
 public static object Read(this IUntypedChannel self, CancellationToken cancelToken)
 {
     return(WaitForTask <object>(ReadAsync(self, new CancellationOffer(cancelToken))).Result);
 }
Beispiel #10
0
 /// <summary>
 /// Gets the IWriteChannel&lt;&gt; interface from an untyped channel instance
 /// </summary>
 /// <returns>The IWriteChannel&lt;&gt; interface.</returns>
 /// <param name="self">The channel to get the interface from</param>
 public static Type WriteInterface(this IUntypedChannel self)
 {
     return(GetImplementedGenericInterface(self, typeof(IWriteChannel <>)));
 }
Beispiel #11
0
 /// <summary>
 /// Requests a write on the channel.
 /// </summary>
 /// <returns>The write request.</returns>
 /// <param name="value">The value to write.</param>
 /// <param name="channel">The channel to write to.</param>
 public IMultisetRequestUntyped RequestWrite(object value, IUntypedChannel channel)
 {
     return((channel as IWriteChannel <T>).RequestWrite((T)value));
 }
Beispiel #12
0
 /// <summary>
 /// Requests a read on the channel.
 /// </summary>
 /// <returns>The read request.</returns>
 /// <param name="channel">The channel to read from.</param>
 public IMultisetRequestUntyped RequestRead(IUntypedChannel channel)
 {
     return((channel as IReadChannel <T>).RequestRead());
 }
Beispiel #13
0
 /// <summary>
 /// Writes the channel and returns the task
 /// </summary>
 /// <returns>The async task.</returns>
 /// <param name="channel">The channel to write to.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="offer">The two-phase offer.</param>
 /// <param name="timeout">The timeout value.</param>
 public Task WriteAsync(IUntypedChannel channel, object value, TimeSpan timeout, ITwoPhaseOffer offer = null)
 {
     return((channel as IWriteChannel <T>).WriteAsync((T)value, timeout, offer));
 }
Beispiel #14
0
 /// <summary>
 /// Reads from the channel and returns the task
 /// </summary>
 /// <returns>The async task.</returns>
 /// <param name="channel">The channel to read from.</param>
 /// <param name="offer">The two-phase offer.</param>
 /// <param name="timeout">The timeout value.</param>
 public async Task <object> ReadAsync(IUntypedChannel channel, TimeSpan timeout, ITwoPhaseOffer offer = null)
 {
     return(await(channel as IReadChannel <T>).ReadAsync(timeout, offer));
 }
Beispiel #15
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 public static object Read(this IUntypedChannel self)
 {
     return(Read(self, null));
 }
Beispiel #16
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="timeout">The read timeout.</param>
 public static object Read(this IUntypedChannel self, TimeSpan timeout)
 {
     return(WaitForTask <object>(ReadAsync(self, new TimeoutOffer(timeout))).Result);
 }
Beispiel #17
0
        /// <summary>
        /// Creates an acessor to an IWriteChannel&lt;&gt;
        /// </summary>
        /// <returns>The accessor.</returns>
        /// <param name="item">The item to create the interface for.</param>
        public static IGenericTypeHelper CreateWriteAccessor(this IUntypedChannel item)
        {
            var writeinterface = WriteInterface(item);

            return((IGenericTypeHelper)Activator.CreateInstance(typeof(GenericTypeHelper <>).MakeGenericType(writeinterface.GenericTypeArguments)));
        }
Beispiel #18
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="timeout">The read timeout.</param>
 /// <param name="cancelToken">The cancellation token.</param>
 public static object Read(this IUntypedChannel self, TimeSpan timeout, CancellationToken cancelToken)
 {
     return(WaitForTask <object>(ReadAsync(self, new TimeoutOffer(timeout, cancelToken))).Result);
 }
Beispiel #19
0
 /// <summary>
 /// Reads from the channel and returns the task
 /// </summary>
 /// <returns>The async task.</returns>
 /// <param name="channel">The channel to read from.</param>
 /// <param name="offer">The two-phase offer.</param>
 public async Task <object> ReadAsync(IUntypedChannel channel, ITwoPhaseOffer offer)
 {
     return(await(channel as IReadChannel <T>).ReadAsync(offer));
 }
Beispiel #20
0
 /// <summary>
 /// Writes the channel synchronously
 /// </summary>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 public static void Write(this IUntypedChannel self, object value)
 {
     Write(self, value, null);
 }
Beispiel #21
0
 /// <summary>
 /// Writes the channel and returns the task
 /// </summary>
 /// <returns>The async task.</returns>
 /// <param name="channel">The channel to write to.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="offer">The two-phase offer.</param>
 public Task WriteAsync(IUntypedChannel channel, object value, ITwoPhaseOffer offer)
 {
     return((channel as IWriteChannel <T>).WriteAsync((T)value, offer));
 }
Beispiel #22
0
 /// <summary>
 /// Writes the channel synchronously
 /// </summary>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="cancelToken">The cancellation token.</param>
 public static void Write(this IUntypedChannel self, object value, CancellationToken cancelToken)
 {
     Write(self, value, new CancellationOffer(cancelToken));
 }
Beispiel #23
0
 /// <summary>
 /// Reads the channel asynchronously.
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="timeout">The read timeout.</param>
 /// <param name="cancelToken">The cancellation token</param>
 public static Task <object> ReadAsync(this IUntypedChannel self, TimeSpan timeout, CancellationToken cancelToken)
 {
     return(UntypedAccessMethods.CreateReadAccessor(self).ReadAsync(self, new TimeoutOffer(timeout, cancelToken)));
 }
Beispiel #24
0
 /// <summary>
 /// Reads the channel asynchronously.
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to read.</param>
 /// <param name="offer">The two-phase offer.</param>
 public static Task <object> ReadAsync(this IUntypedChannel self, ITwoPhaseOffer offer)
 {
     return(UntypedAccessMethods.CreateReadAccessor(self).ReadAsync(self, offer));
 }
Beispiel #25
0
 /// <summary>
 /// Writes the channel asynchronously
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to write.</param>
 /// <param name="value">The value to write.</param>
 /// <param name="timeout">The write timeout.</param>
 /// <param name="cancelToken">The cancellation token</param>
 public static Task WriteAsync(this IUntypedChannel self, object value, TimeSpan timeout, CancellationToken cancelToken)
 {
     return(UntypedAccessMethods.CreateWriteAccessor(self).WriteAsync(self, value, new TimeoutOffer(timeout, cancelToken)));
 }
Beispiel #26
0
 /// <summary>
 /// Reads the channel asynchronously.
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to read.</param>
 public static Task <object> ReadAsync(this IUntypedChannel self)
 {
     return(ReadAsync(self, null));
 }
Beispiel #27
0
 /// <summary>
 /// Writes the channel asynchronously
 /// </summary>
 /// <returns>The task for awaiting completion.</returns>
 /// <param name="self">The channel to write.</param>
 /// <param name="offer">The two-phase offer.</param>
 /// <param name="value">The value to write.</param>
 public static Task WriteAsync(this IUntypedChannel self, object value, ITwoPhaseOffer offer)
 {
     return(UntypedAccessMethods.CreateWriteAccessor(self).WriteAsync(self, value, offer));
 }
Beispiel #28
0
 /// <summary>
 /// Create a write request for the given channel.
 /// </summary>
 /// <param name="self">The channel to request the write to.</param>
 /// <param name="value">The value to write.</param>
 /// <returns>The created request</returns>
 public static IMultisetRequestUntyped RequestWrite(this IUntypedChannel self, object value)
 {
     return(UntypedAccessMethods.CreateWriteAccessor(self).RequestWrite(value, self));
 }
Beispiel #29
0
 /// <summary>
 /// Reads the channel synchronously.
 /// </summary>
 /// <returns>The value read.</returns>
 /// <param name="self">The channel to read.</param>
 public static object Read(this IUntypedChannel self)
 {
     return(Read(self, Timeout.Infinite, null));
 }