internal virtual Message RequestCorrelated(Message msg, TimeSpan timeout, IOutputChannel channel) { // FIXME: implement ConcurrencyMode check: // if it is .Single && this instance for a callback channel && the operation is invoked inside service operation, then error. DateTime startTime = DateTime.Now; OutputChannel.Send(msg, timeout); return(((IDuplexChannel)channel).Receive(timeout - (DateTime.Now - startTime))); }
private void Output_OnError(object sender, ChannelErrorEventArgs e) { logger?.LogError(e.Error, "Fault in output channel."); if (!outputDisposed) { //restart the channel ExecuteOutputRetryPolicyAsync().Wait(); OutputChannel.OpenAsync().GetAwaiter(); } }
void Output(OperationDescription od, object [] parameters) { if (OutputChannel.State != CommunicationState.Opened) { OutputChannel.Open(); } ClientOperation op = runtime.Operations [od.Name]; Send(CreateRequest(op, parameters), OperationTimeout); }
internal void Send(Message msg, TimeSpan timeout) { if (OutputChannel != null) { OutputChannel.Send(msg, timeout); } else { RequestChannel.Request(msg, timeout); } }
internal void Send(Message msg, TimeSpan timeout) { if (OutputChannel != null) { OutputChannel.Send(msg, timeout); } else { RequestChannel.Request(msg, timeout); // and ignore returned message. } }
public void InsertChannel(OutputChannel channel) { _channels.AddLast(channel); channel.ParentFixture = this; // If there is no name for this fixture and it's the first channel // being added, give it a default name. if (string.IsNullOrWhiteSpace(Name) && _channels.Count == 1) { Name = channel.Name; } }
public async Task Create(OutputChannel channel) { await _outputChannelDa.AddOutputChannel(channel); _kafkaProducer.Produce(Constants.EventSourcingTopicName, new OutputChannelModificationInfo { ModificationType = OutputChannelModificationType.ADD, OutputChannel = channel } ); }
public void ReadNull() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); output.Write(null); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.IsNull(channel.Read()); }
public void ReadInteger() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); output.Write(123); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(123, channel.Read()); }
public void ReadShortInteger() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); short sh = short.MaxValue; output.Write(sh); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(sh, channel.Read()); }
public void ReadLongInteger() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); long ln = long.MaxValue; output.Write(ln); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(ln, channel.Read()); }
public void ReadDecimal() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); decimal dc = 12.34m; output.Write(dc); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(dc, channel.Read()); }
public void ReadByte() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); byte bt = 64; output.Write(bt); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(bt, channel.Read()); }
// They are internal for ClientBase<T>.ChannelBase use. internal Message Request(Message msg, TimeSpan timeout) { if (RequestChannel != null) { return(RequestChannel.Request(msg, timeout)); } else { DateTime startTime = DateTime.Now; OutputChannel.Send(msg, timeout); return(((IDuplexChannel)OutputChannel).Receive(timeout - (DateTime.Now - startTime))); } }
public void ReadCharacter() { MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); char ch = 'a'; output.Write(ch); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); Assert.AreEqual(ch, channel.Read()); }
public override int GetHashCode() { int hash = 1; if (OutputChannel.Length != 0) { hash ^= OutputChannel.GetHashCode(); } if (ImagePoolSize != 0) { hash ^= ImagePoolSize.GetHashCode(); } return(hash); }
private IEnumerable <Paragraph> GetParagraphs(OutputChannel channel) { if (OutputArgs != null) { var xml = ParseContent(OutputArgs.Package[channel]); foreach (var paragraph in xml.Elements("Paragraph")) { yield return(new Paragraph { Inlines = ExpandInlines(paragraph.Nodes()).ToArray() }); } } }
private void Output_OnClose(object sender, ChannelCloseEventArgs e) { try { logger?.LogWarning("Output channel closed."); logger?.LogInformation("Restarting output channel."); ExecuteOutputRetryPolicy(); OutputChannel.OpenAsync().GetAwaiter(); } catch (Exception ex) { logger?.LogError(ex, "Fault restarting module output channel."); throw ex; } }
public bool Allocate() { if (_allocated) { return(false); } _out = new OutputChannel(); _instrument = new byte[23]; _out.effectDefA.envelope = _out.effectEnvelopeA; _out.effectDefB.envelope = _out.effectEnvelopeB; _allocated = true; return(true); }
public void WriteAndReadTwoPersonObjects() { var person = new Person() { Id = 1, FirstName = "John", LastName = "Smith" }; var person2 = new Person() { Id = 2, FirstName = "Adam", LastName = "Pearson" }; MemoryStream stream = new MemoryStream(); OutputChannel output = new OutputChannel(new BinaryWriter(stream)); output.Write(person); output.Write(person2); stream.Seek(0, SeekOrigin.Begin); InputChannel channel = new InputChannel(new BinaryReader(stream)); var result = channel.Read(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Person)); var newperson = (Person)result; Assert.AreEqual(person.Id, newperson.Id); Assert.AreEqual(person.FirstName, newperson.FirstName); Assert.AreEqual(person.LastName, newperson.LastName); result = channel.Read(); Assert.IsNotNull(result); Assert.IsInstanceOfType(result, typeof(Person)); var newperson2 = (Person)result; Assert.AreEqual(person2.Id, newperson2.Id); Assert.AreEqual(person2.FirstName, newperson2.FirstName); Assert.AreEqual(person2.LastName, newperson2.LastName); }
public void WriteNull() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); channel.Write(null); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Null, reader.ReadByte()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteFloat() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); channel.Write((float)123.45); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Single, reader.ReadByte()); Assert.AreEqual((float)123.45, reader.ReadSingle()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
/// <inheritdoc /> public override void Dispose() { InputChannel.NewOutMessage -= InputChannelOnNewOutMessage; OutputChannel.NewOutMessage -= OutputChannelOnNewOutMessage; if (OwnInputChannel) { InputChannel.Dispose(); } if (OwnOutputChannel) { OutputChannel.Dispose(); } base.Dispose(); }
void IDisposable.Dispose() { InputChannel.NewOutMessage -= InputChannelOnNewOutMessage; OutputChannel.NewOutMessage -= OutputChannelOnNewOutMessage; if (OwnInputChannel) { InputChannel.Dispose(); } if (OwnOutputChannel) { OutputChannel.Dispose(); } Adapter.NewOutMessage -= AdapterOnNewOutMessage; //Adapter.Dispose(); }
protected void Disposing(bool dispose) { if (dispose & !disposed) { disposed = true; try { InputFilters.Clear(); OutputFilters.Clear(); InputChannel.Dispose(); OutputChannel.Dispose(); } catch (Exception ex) { logger?.LogError(ex, "Fault disposing vrtu pipeline."); } } }
get => new MixtureSettings() { widthScale = 1.0f, heightScale = 1.0f, depthScale = 1.0f, width = 1024, height = 1024, depth = 1, sizeMode = OutputSizeMode.InheritFromParent, dimension = OutputDimension.InheritFromParent, outputChannels = OutputChannel.InheritFromParent, outputPrecision = OutputPrecision.InheritFromParent, editFlags = ~EditFlags.POTSize, doubleBuffered = false, wrapMode = OutputWrapMode.InheritFromParent, filterMode = OutputFilterMode.InheritFromParent, refreshMode = RefreshMode.OnLoad, };
public void WriteShortInteger() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); short sh = 123; channel.Write(sh); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Short, reader.ReadByte()); Assert.AreEqual(sh, reader.ReadInt16()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void Send(Message message, TimeSpan timeout) { if (message == null) { throw new ArgumentNullException(nameof(message)); } WcfClientEventSource.Log.ChannelCalled(GetType().FullName, nameof(Send)); var telemetry = StartSendTelemetry(message, nameof(Send)); try { OutputChannel.Send(message, timeout); StopSendTelemetry(telemetry, null, null, nameof(Send)); } catch (Exception ex) { StopSendTelemetry(telemetry, null, ex, nameof(Send)); throw; } }
public void WriteLongInteger() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); long ln = 123; channel.Write(ln); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Long, reader.ReadByte()); Assert.AreEqual(ln, reader.ReadInt64()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void WriteDecimal() { MemoryStream stream = new MemoryStream(); OutputChannel channel = new OutputChannel(new BinaryWriter(stream)); decimal dc = 12.34m; channel.Write(dc); stream.Seek(0, SeekOrigin.Begin); BinaryReader reader = new BinaryReader(stream); Assert.AreEqual((byte)Types.Decimal, reader.ReadByte()); Assert.AreEqual(dc, reader.ReadDecimal()); Assert.AreEqual(-1, reader.PeekChar()); reader.Close(); }
public void Send_Serializes_And_Sends_Message_To_Stream() { string message = "Another message"; byte[] expectedBytes = Encoding.UTF8.GetBytes(message); byte[] actualBytes = null; var stream = A.Fake<IOutputStream>(); A.CallTo(() => stream.Send(A<byte[]>._, A<int>._, A<int>._)).Invokes(foc => { var buffer = foc.GetArgument<byte[]>(0); var offset = foc.GetArgument<int>(1); var count = foc.GetArgument<int>(2); actualBytes = buffer.Skip(offset).Take(count).ToArray(); }); var channel = new OutputChannel<string>(stream, new StringSerializer(), 1024); channel.Send(message); CollectionAssert.AreEqual(expectedBytes, actualBytes); }
// Keeping the same interface as a fixture so it will be familiar. public void InsertChannel(OutputChannel channel) { _channels.AddLast(channel); }
public bool Allocate() { if (_allocated) return false; _out = new OutputChannel(); _instrument = new byte[23]; _out.effectDefA.envelope = _out.effectEnvelopeA; _out.effectDefB.envelope = _out.effectEnvelopeB; _allocated = true; return true; }