/// <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(); } }
/// <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(); } }
/// <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); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
/// <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); }
/// <summary> /// Gets the IWriteChannel<> interface from an untyped channel instance /// </summary> /// <returns>The IWriteChannel<> 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 <>))); }
/// <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)); }
/// <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()); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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); }
/// <summary> /// Creates an acessor to an IWriteChannel<> /// </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))); }
/// <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); }
/// <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)); }
/// <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); }
/// <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)); }
/// <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)); }
/// <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))); }
/// <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)); }
/// <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))); }
/// <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)); }
/// <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)); }
/// <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)); }
/// <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)); }