當前位置: 首頁>>代碼示例>>C#>>正文


C# Message.GetField方法代碼示例

本文整理匯總了C#中QuickFix.Message.GetField方法的典型用法代碼示例。如果您正苦於以下問題:C# Message.GetField方法的具體用法?C# Message.GetField怎麽用?C# Message.GetField使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在QuickFix.Message的用法示例。


在下文中一共展示了Message.GetField方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: SendRaw

        protected bool SendRaw(Message message, int seqNum)
        {
            lock (sync_)
            {
                string msgType = message.Header.GetField(Fields.Tags.MsgType);

                InitializeHeader(message, seqNum);

                if (Message.IsAdminMsgType(msgType))
                {
                    this.Application.ToAdmin(message, this.SessionID);

                    if (MsgType.LOGON.Equals(msgType) && !state_.ReceivedReset)
                    {
                        Fields.ResetSeqNumFlag resetSeqNumFlag = new QuickFix.Fields.ResetSeqNumFlag(false);
                        if (message.IsSetField(resetSeqNumFlag))
                            message.GetField(resetSeqNumFlag);
                        if (resetSeqNumFlag.getValue())
                        {
                            state_.Reset();
                            message.Header.SetField(new Fields.MsgSeqNum(state_.GetNextSenderMsgSeqNum()));
                        }
                        state_.SentReset = resetSeqNumFlag.Obj;
                    }
                }
                else
                {
                    this.Application.ToApp(message, this.SessionID);
                }

                string messageString = message.ToString();
                if (0 == seqNum)
                    Persist(message, messageString);
                return Send(messageString);
            }
        }
開發者ID:thomasfleming,項目名稱:quickfixn,代碼行數:36,代碼來源:Session.cs

示例2: GenerateHeartbeat

 public bool GenerateHeartbeat(Message testRequest)
 {
     Message heartbeat = msgFactory_.Create(this.SessionID.BeginString, Fields.MsgType.HEARTBEAT);
     InitializeHeader(heartbeat);
     try
     {
         heartbeat.SetField(new Fields.TestReqID(testRequest.GetField(Fields.Tags.TestReqID)));
         if (this.EnableLastMsgSeqNumProcessed)
         {
             heartbeat.Header.SetField(new Fields.LastMsgSeqNumProcessed(testRequest.Header.GetInt(Tags.MsgSeqNum)));
         }
     }
     catch (FieldNotFoundException)
     { }
     return SendRaw(heartbeat, 0);
 }
開發者ID:thomasfleming,項目名稱:quickfixn,代碼行數:16,代碼來源:Session.cs

示例3: ProcessNOS

        protected void ProcessNOS(Message message, SessionID sessionID)
        {
            Message echo = new Message(message);

                bool possResend = false;
                if (message.Header.IsSetField(QuickFix.Fields.Tags.PossResend))
                    possResend = message.Header.GetBoolean(QuickFix.Fields.Tags.PossResend);

                KeyValuePair<string, SessionID> pair = new KeyValuePair<string, SessionID>(message.GetField(QuickFix.Fields.Tags.ClOrdID), sessionID);
                if (possResend && clOrdIDs_.Contains(pair))
                    return;
                clOrdIDs_.Add(pair);

            Session.SendToTarget(echo, sessionID);
        }
開發者ID:nisbus,項目名稱:quickfixn,代碼行數:15,代碼來源:ATApplication.cs

示例4: NextLogon

        protected void NextLogon(Message logon)
        {
            Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false);
            if (logon.IsSetField(resetSeqNumFlag))
                logon.GetField(resetSeqNumFlag);
            state_.ReceivedReset = resetSeqNumFlag.Obj;

            if (!state_.IsInitiator && this.ResetOnLogon)
                state_.Reset();

            if (!Verify(logon, false, true))
                return;

            if (!IsGoodTime(logon))
            {
                this.Log.OnEvent("Logon had bad sending time");
                Disconnect("bad sending time");
                return;
            }

            state_.ReceivedLogon = true;
            this.Log.OnEvent("Received logon");
            if (!state_.IsInitiator)
            {
                int heartBtInt = logon.GetInt(Fields.Tags.HeartBtInt);
                state_.HeartBtInt = heartBtInt;
                GenerateLogon(logon);
                this.Log.OnEvent("Responding to logon request");
            }

            state_.SentReset = false;
            state_.ReceivedReset = false;

            int msgSeqNum = logon.Header.GetInt(Fields.Tags.MsgSeqNum);
            if (IsTargetTooHigh(msgSeqNum) && !resetSeqNumFlag.Obj)
            {
                DoTargetTooHigh(logon, msgSeqNum);
            }
            else
            {
                state_.IncrNextTargetMsgSeqNum();
                NextQueued();
            }

            if (this.IsLoggedOn)
                this.Application.OnLogon(this.SessionID);
        }
開發者ID:thomasfleming,項目名稱:quickfixn,代碼行數:47,代碼來源:Session.cs

示例5: SetFieldsTest

        public void SetFieldsTest()
        {
            var message = new Message();
            var allocId = new AllocID("123456");
            var allocAccount = new AllocAccount("QuickFixAccount");
            var allocAccountType = new AllocAccountType(AllocAccountType.HOUSE_TRADER);
            message.SetFields(new IField[] { allocAccount, allocAccountType, allocId });

            Assert.AreEqual(true, message.IsSetField(Tags.AllocID));
            Assert.AreEqual("123456", message.GetField(Tags.AllocID));

            Assert.AreEqual(true, message.IsSetField(Tags.AllocAccount));
            Assert.AreEqual("QuickFixAccount", message.GetField(Tags.AllocAccount));

            Assert.AreEqual(true, message.IsSetField(Tags.AllocAccountType));
            Assert.AreEqual(AllocAccountType.HOUSE_TRADER, message.GetInt(Tags.AllocAccountType));
        }
開發者ID:RemiGaudin,項目名稱:quickfixn,代碼行數:17,代碼來源:MessageTests.cs

示例6: GetMsgType

 /// <summary>
 /// FIXME totally bogus
 /// </summary>
 /// <param name="msg"></param>
 /// <returns></returns>
 public static string GetMsgType(string msg)
 {
     Message FIXME = new Message(msg);
     return FIXME.GetField(Tags.MsgType);
 }
開發者ID:shanetrotter,項目名稱:quickfixn,代碼行數:10,代碼來源:Message.cs

示例7: FromStringTestWithNoDataDictionary

 public void FromStringTestWithNoDataDictionary()
 {
     string str1 = "8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" +
         "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01";
     Message msg = new Message();
     try
     {
         msg.FromString(str1, true, null, null, _defaultMsgFactory);
     }
     catch (InvalidMessage e)
     {
         Assert.Fail("Unexpected exception (InvalidMessage): " + e.Message);
     }
     StringField f1 = new StringField(8);
     StringField f2 = new StringField(9);
     StringField f3 = new StringField(35);
     StringField f4 = new StringField(34);
     StringField f5 = new StringField(49);
     StringField f6 = new StringField(52);
     StringField f7 = new StringField(56);
     StringField f8 = new StringField(10);
     StringField f9 = new StringField(1);
     msg.Header.GetField(f1);
     msg.Header.GetField(f2);
     msg.Header.GetField(f3);
     msg.Header.GetField(f4);
     msg.Header.GetField(f5);
     msg.Header.GetField(f6);
     msg.Header.GetField(f7);
     msg.GetField(f9);
     msg.Trailer.GetField(f8);
     Assert.That(f1.Obj, Is.EqualTo("FIX.4.2"));
     Assert.That(f2.Obj, Is.EqualTo("55"));
     Assert.That(f3.Obj, Is.EqualTo("0"));
     Assert.That(f4.Obj, Is.EqualTo("3"));
     Assert.That(f5.Obj, Is.EqualTo("TW"));
     Assert.That(f6.Obj, Is.EqualTo("20000426-12:05:06"));
     Assert.That(f7.Obj, Is.EqualTo("ISLD"));
     Assert.That(f8.Obj, Is.EqualTo("123"));
     Assert.That(f9.Obj, Is.EqualTo("acct123"));
 }
開發者ID:RemiGaudin,項目名稱:quickfixn,代碼行數:41,代碼來源:MessageTests.cs

示例8: NextLogon

        protected void NextLogon(Message logon)
        {
            Fields.ResetSeqNumFlag resetSeqNumFlag = new Fields.ResetSeqNumFlag(false);
            if (logon.IsSetField(resetSeqNumFlag))
                logon.GetField(resetSeqNumFlag);
            state_.ReceivedReset = resetSeqNumFlag.Obj;

            if (state_.ReceivedReset)
            {
                this.Log.OnEvent("Sequence numbers reset due to ResetSeqNumFlag=Y");
                if (!state_.SentReset)
                {
                    state_.Reset("Reset requested by counterparty");
                }
            }

            if (!state_.IsInitiator && this.ResetOnLogon)
                state_.Reset("ResetOnLogon");
            if (this.RefreshOnLogon)
                Refresh();

            if (!Verify(logon, false, true))
                return;

            if (!IsGoodTime(logon))
            {
                this.Log.OnEvent("Logon has bad sending time");
                Disconnect("bad sending time");
                return;
            }

            state_.ReceivedLogon = true;
            this.Log.OnEvent("Received logon");
            if (!state_.IsInitiator)
            {
                int heartBtInt = logon.GetInt(Fields.Tags.HeartBtInt);
                state_.HeartBtInt = (int)Math.Floor(heartBtInt / (double)2);
                GenerateLogon(logon);
                this.Log.OnEvent("Responding to logon request");
            }

            state_.SentReset = false;
            state_.ReceivedReset = false;

            int msgSeqNum = logon.Header.GetInt(Fields.Tags.MsgSeqNum);
            if (IsTargetTooHigh(msgSeqNum) && !resetSeqNumFlag.Obj)
            {
                DoTargetTooHigh(logon, msgSeqNum);
            }
            else
            {
                state_.IncrNextTargetMsgSeqNum();
            }

            if (this.IsLoggedOn)
                this.Application.OnLogon(this.SessionID);
        }
開發者ID:kevholditch,項目名稱:quickfixn,代碼行數:57,代碼來源:Session.cs

示例9: SendRaw

        protected bool SendRaw(Message message, int seqNum)
        {
            
            lock (sync_)
            {
                string msgType = message.Header.GetField(Fields.Tags.MsgType);
                if (msgType == Fields.MsgType.HEARTBEAT)
                {
                    _log.Info("Sending heartbeat inside sendraw");
                }

                InitializeHeader(message, seqNum);

                if (Message.IsAdminMsgType(msgType))
                {
                    this.Application.ToAdmin(message, this.SessionID);

                    if (MsgType.LOGON.Equals(msgType) && !state_.ReceivedReset)
                    {
                        Fields.ResetSeqNumFlag resetSeqNumFlag = new QuickFix.Fields.ResetSeqNumFlag(false);
                        if (message.IsSetField(resetSeqNumFlag))
                            message.GetField(resetSeqNumFlag);
                        if (resetSeqNumFlag.getValue())
                        {
                            state_.Reset("ResetSeqNumFlag");
                            message.Header.SetField(new Fields.MsgSeqNum(state_.GetNextSenderMsgSeqNum()));
                        }
                        state_.SentReset = resetSeqNumFlag.Obj;
                    }
                }
                else
                {
                    try
                    {
                        this.Application.ToApp(message, this.SessionID);
                    }
                    catch (DoNotSend)
                    {
                        return false;
                    }
                }

                string messageString = message.ToString();
                if (0 == seqNum)
                    Persist(message, messageString);
                
                if (msgType == Fields.MsgType.HEARTBEAT)
                {
                    _log.Info("about to send that heartbeat for real");
                }

                return Send(messageString, msgType == Fields.MsgType.HEARTBEAT);
            }
        }
開發者ID:kevholditch,項目名稱:quickfixn,代碼行數:54,代碼來源:Session.cs

示例10: ToXMLTest

        public void ToXMLTest()
        {
            string str1 = "8=FIX.4.2\x01" + "9=55\x01" + "35=0\x01" + "34=3\x01" + "49=TW\x01" +
                "52=20000426-12:05:06\x01" + "56=ISLD\x01" + "1=acct123\x01" + "10=123\x01";
            Message msg = new Message();
            try
            {
                msg.FromString(str1, true, null, null, _defaultMsgFactory);
            }
            catch (InvalidMessage e)
            {
                Assert.Fail("Unexpected exception (InvalidMessage): " + e.Message);
            }

            string xmlDoc = msg.toXML();
            XDocument doc = null;
            try
            {
                doc = XDocument.Parse(xmlDoc);
            }
            catch (Exception e)
            {
                Assert.Fail("Badly formed XML generated: " + e.Message);
            }

            var fields = doc.Descendants("message").Descendants("body")
                .Select(field =>
                    new
                    {
                        number = field.Descendants("field").Attributes("number").Single().Value,
                        value = field.Descendants("field").Single().Value
                    })
                    .ToList();

            foreach (var elem in fields)
            {
                int number = 0;
                if (int.TryParse(elem.number.ToString(), out number) == false)
                {
                    Assert.Fail("should be number " + elem.number.ToString() + " " + elem.value.ToString());
                }
                else
                {
                    string value = msg.GetField(number);
                    Assert.That(value, Is.EqualTo(elem.value));
                }
            }

        }
開發者ID:baffled,項目名稱:quickfixn,代碼行數:49,代碼來源:MessageTests.cs

示例11: TestMessageParserIntegrity

        public void TestMessageParserIntegrity()
        {
            string fix = "5=ASDF" + Message.SOH + "10=234" + Message.SOH;

            Message m = new Message();
            StringField sf = new StringField(0);

            MakeMessage(m, fix);

            Assert.That(m.GetField(5), Is.EqualTo("ASDF"));
            Assert.That(m.GetField(10), Is.EqualTo("234"));
        }
開發者ID:kennystone,項目名稱:quickfixn,代碼行數:12,代碼來源:PerformanceTests.cs


注:本文中的QuickFix.Message.GetField方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。