Exemplo n.º 1
0
        private TRet ProjectSubMessage <TRet>(FudgeMsg retMsg, string subMessageField)
        {
            if (retMsg == null)
            {
                return(default(TRet));
            }
            FudgeSerializer fudgeSerializer = _fudgeContext.GetSerializer();
            var             subMessage      = retMsg.GetMessage(subMessageField);

            if (subMessage == null)
            {
                return(default(TRet));
            }
            return(fudgeSerializer.Deserialize <TRet>((FudgeMsg)subMessage));
        }
Exemplo n.º 2
0
        public void AddingFieldContainerCopiesFields()
        {
            var msg = new FudgeMsg();

            // Add a normal sub-message (shouldn't copy)
            IFudgeFieldContainer sub1 = new FudgeMsg(new Field("age", 37));
            msg.Add("sub1", sub1);
            Assert.Same(sub1, msg.GetValue("sub1"));

            // Add a sub-message that isn't a FudgeMsg (should copy)
            IFudgeFieldContainer sub2 = (IFudgeFieldContainer)new Field("dummy", new Field("colour", "blue")).Value;
            Assert.IsNotType<FudgeMsg>(sub2);       // Just making sure
            msg.Add("sub2", sub2);
            Assert.NotSame(sub2, msg.GetValue("sub2"));
            Assert.IsType<FudgeMsg>(msg.GetValue("sub2"));
            Assert.Equal("blue", msg.GetMessage("sub2").GetString("colour"));
        }
Exemplo n.º 3
0
        public void AddingFieldContainerCopiesFields()
        {
            var msg = new FudgeMsg();

            // Add a normal sub-message (shouldn't copy)
            IFudgeFieldContainer sub1 = new FudgeMsg(new Field("age", 37));

            msg.Add("sub1", sub1);
            Assert.Same(sub1, msg.GetValue("sub1"));

            // Add a sub-message that isn't a FudgeMsg (should copy)
            IFudgeFieldContainer sub2 = (IFudgeFieldContainer) new Field("dummy", new Field("colour", "blue")).Value;

            Assert.IsNotType <FudgeMsg>(sub2);       // Just making sure
            msg.Add("sub2", sub2);
            Assert.NotSame(sub2, msg.GetValue("sub2"));
            Assert.IsType <FudgeMsg>(msg.GetValue("sub2"));
            Assert.Equal("blue", msg.GetMessage("sub2").GetString("colour"));
        }
        private Tuple <UniqueId, ILocalDateDoubleTimeSeries> DecodePairMessage(FudgeMsg message)
        {
            if (message == null)
            {
                return(new Tuple <UniqueId, ILocalDateDoubleTimeSeries>(null, null));
            }

            var uniqueIdString = message.GetString("uniqueId");

            if (uniqueIdString == null)
            {
                throw new ArgumentException("uniqueId not present in message");
            }
            var timeSeriesField = (FudgeMsg)message.GetMessage("timeSeries");

            if (timeSeriesField == null)
            {
                throw new ArgumentException("timeSeries not present in message");
            }
            return(Tuple.Create(UniqueId.Parse(uniqueIdString), _fudgeContext.GetSerializer().Deserialize <ILocalDateDoubleTimeSeries>(timeSeriesField)));
        }
        private Tuple<UniqueId, ILocalDateDoubleTimeSeries> DecodePairMessage(FudgeMsg message)
        {
            if (message == null)
            {
                return new Tuple<UniqueId, ILocalDateDoubleTimeSeries>(null, null);
            }

            var uniqueIdString = message.GetString("uniqueId");
            if (uniqueIdString == null)
            {
                throw new ArgumentException("uniqueId not present in message");
            }
            var timeSeriesField = (FudgeMsg)message.GetMessage("timeSeries");
            if (timeSeriesField == null)
            {
                throw new ArgumentException("timeSeries not present in message");
            }
            return Tuple.Create(UniqueId.Parse(uniqueIdString), _fudgeContext.GetSerializer().Deserialize<ILocalDateDoubleTimeSeries>(timeSeriesField));
        }