public virtual T GetOption <T>(ChannelOption <T> option) { if (option is null) { ThrowHelper.ThrowArgumentNullException(ExceptionArgument.option); } if (ChannelOption.ConnectTimeout.Equals(option)) { return((T)(object)ConnectTimeout); // no boxing will happen, compiler optimizes away such casts } if (ChannelOption.WriteSpinCount.Equals(option)) { return((T)(object)WriteSpinCount); } if (ChannelOption.Allocator.Equals(option)) { return((T)Allocator); } if (ChannelOption.RcvbufAllocator.Equals(option)) { return((T)RecvByteBufAllocator); } if (ChannelOption.AutoRead.Equals(option)) { return((T)(object)IsAutoRead); } if (ChannelOption.AutoClose.Equals(option)) { return((T)(object)IsAutoClose); } if (ChannelOption.WriteBufferHighWaterMark.Equals(option)) { return((T)(object)WriteBufferHighWaterMark); } if (ChannelOption.WriteBufferLowWaterMark.Equals(option)) { return((T)(object)WriteBufferLowWaterMark); } if (ChannelOption.MessageSizeEstimator.Equals(option)) { return((T)MessageSizeEstimator); } if (ChannelOption.MaxMessagesPerRead.Equals(option)) { if (RecvByteBufAllocator is IMaxMessagesRecvByteBufAllocator) { return((T)(object)MaxMessagesPerRead); } } if (ChannelOption.SingleEventexecutorPerGroup.Equals(option)) { return((T)(object)PinEventExecutorPerGroup); } return(default);
public virtual bool SetOption <T>(ChannelOption <T> option, T value) { this.Validate(option, value); if (ChannelOption.ConnectTimeout.Equals(option)) { this.ConnectTimeout = (TimeSpan)(object)value; } else if (ChannelOption.MaxMessagesPerRead.Equals(option)) { this.MaxMessagesPerRead = (int)(object)value; } else if (ChannelOption.WriteSpinCount.Equals(option)) { this.WriteSpinCount = (int)(object)value; } else if (ChannelOption.Allocator.Equals(option)) { this.Allocator = (IByteBufferAllocator)value; } else if (ChannelOption.RcvbufAllocator.Equals(option)) { this.RecvByteBufAllocator = (IRecvByteBufAllocator)value; } else if (ChannelOption.AutoRead.Equals(option)) { this.AutoRead = (bool)(object)value; } else if (ChannelOption.WriteBufferHighWaterMark.Equals(option)) { this.writeBufferHighWaterMark = (int)(object)value; } else if (ChannelOption.WriteBufferLowWaterMark.Equals(option)) { this.WriteBufferLowWaterMark = (int)(object)value; } else if (ChannelOption.MessageSizeEstimator.Equals(option)) { this.MessageSizeEstimator = (IMessageSizeEstimator)value; } else { return(false); } return(true); }
public virtual T GetOption <T>(ChannelOption <T> option) { Contract.Requires(option != null); if (ChannelOption.ConnectTimeout.Equals(option)) { return((T)(object)this.ConnectTimeout); // no boxing will happen, compiler optimizes away such casts } if (ChannelOption.MaxMessagesPerRead.Equals(option)) { return((T)(object)this.MaxMessagesPerRead); } if (ChannelOption.WriteSpinCount.Equals(option)) { return((T)(object)this.WriteSpinCount); } if (ChannelOption.Allocator.Equals(option)) { return((T)this.Allocator); } if (ChannelOption.RcvbufAllocator.Equals(option)) { return((T)this.RecvByteBufAllocator); } if (ChannelOption.AutoRead.Equals(option)) { return((T)(object)this.AutoRead); } if (ChannelOption.WriteBufferHighWaterMark.Equals(option)) { return((T)(object)this.WriteBufferHighWaterMark); } if (ChannelOption.WriteBufferLowWaterMark.Equals(option)) { return((T)(object)this.WriteBufferLowWaterMark); } if (ChannelOption.MessageSizeEstimator.Equals(option)) { return((T)this.MessageSizeEstimator); } return(default(T)); }
public bool SetOption(ChannelOption option, object value) => option.Set(this, value);
protected virtual void Validate <T>(ChannelOption <T> option, T value) { Contract.Requires(option != null); option.Validate(value); }
public bool SetOption(ChannelOption option, object value) { return(option.Set(this, value)); }