Esempio n. 1
0
        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)));
        }
Esempio n. 2
0
        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();
            }
        }
Esempio n. 3
0
        void Output(OperationDescription od, object [] parameters)
        {
            if (OutputChannel.State != CommunicationState.Opened)
            {
                OutputChannel.Open();
            }

            ClientOperation op = runtime.Operations [od.Name];

            Send(CreateRequest(op, parameters), OperationTimeout);
        }
Esempio n. 4
0
 internal void Send(Message msg, TimeSpan timeout)
 {
     if (OutputChannel != null)
     {
         OutputChannel.Send(msg, timeout);
     }
     else
     {
         RequestChannel.Request(msg, timeout);
     }
 }
Esempio n. 5
0
 internal void Send(Message msg, TimeSpan timeout)
 {
     if (OutputChannel != null)
     {
         OutputChannel.Send(msg, timeout);
     }
     else
     {
         RequestChannel.Request(msg, timeout);                  // and ignore returned message.
     }
 }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
        public async Task Create(OutputChannel channel)
        {
            await _outputChannelDa.AddOutputChannel(channel);

            _kafkaProducer.Produce(Constants.EventSourcingTopicName,
                                   new OutputChannelModificationInfo
            {
                ModificationType = OutputChannelModificationType.ADD,
                OutputChannel    = channel
            }
                                   );
        }
Esempio n. 8
0
        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());
        }
Esempio n. 9
0
        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());
        }
Esempio n. 10
0
        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());
        }
Esempio n. 11
0
        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());
        }
Esempio n. 12
0
        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());
        }
Esempio n. 13
0
        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());
        }
Esempio n. 14
0
 // 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)));
     }
 }
Esempio n. 15
0
        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());
        }
Esempio n. 16
0
                public override int GetHashCode()
                {
                    int hash = 1;

                    if (OutputChannel.Length != 0)
                    {
                        hash ^= OutputChannel.GetHashCode();
                    }
                    if (ImagePoolSize != 0)
                    {
                        hash ^= ImagePoolSize.GetHashCode();
                    }
                    return(hash);
                }
Esempio n. 17
0
        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()
                    });
                }
            }
        }
Esempio n. 18
0
 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;
     }
 }
Esempio n. 19
0
            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);
            }
Esempio n. 20
0
        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);
        }
Esempio n. 21
0
        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();
        }
Esempio n. 22
0
        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();
        }
Esempio n. 23
0
        /// <inheritdoc />
        public override void Dispose()
        {
            InputChannel.NewOutMessage  -= InputChannelOnNewOutMessage;
            OutputChannel.NewOutMessage -= OutputChannelOnNewOutMessage;

            if (OwnInputChannel)
            {
                InputChannel.Dispose();
            }

            if (OwnOutputChannel)
            {
                OutputChannel.Dispose();
            }

            base.Dispose();
        }
Esempio n. 24
0
        void IDisposable.Dispose()
        {
            InputChannel.NewOutMessage  -= InputChannelOnNewOutMessage;
            OutputChannel.NewOutMessage -= OutputChannelOnNewOutMessage;

            if (OwnInputChannel)
            {
                InputChannel.Dispose();
            }

            if (OwnOutputChannel)
            {
                OutputChannel.Dispose();
            }

            Adapter.NewOutMessage -= AdapterOnNewOutMessage;
            //Adapter.Dispose();
        }
Esempio n. 25
0
 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.");
         }
     }
 }
Esempio n. 26
0
 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,
 };
Esempio n. 27
0
        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();
        }
Esempio n. 28
0
        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;
            }
        }
Esempio n. 29
0
        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();
        }
Esempio n. 30
0
        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();
        }
Esempio n. 31
0
        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);
        }
Esempio n. 32
0
 // Keeping the same interface as a fixture so it will be familiar.
 public void InsertChannel(OutputChannel channel)
 {
     _channels.AddLast(channel);
 }
Esempio n. 33
0
            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;
            }