QuickFix.SessionSettings.ToString C# (CSharp) Method

ToString() public method

public ToString ( ) : string
return string
        public override string ToString()
        {
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            s.AppendLine("[DEFAULT]");

            foreach (System.Collections.Generic.KeyValuePair<string, string> entry in defaults_)
                s.Append(entry.Key).Append('=').AppendLine(entry.Value);

            foreach (KeyValuePair<SessionID, QuickFix.Dictionary> entry in settings_)
            {
                s.AppendLine().AppendLine("[SESSION]");
                foreach (System.Collections.Generic.KeyValuePair<string, string> kvp in entry.Value)
                {
                    if (defaults_.Has(kvp.Key) && defaults_.GetString(kvp.Key).Equals(kvp.Value))
                        continue;
                    s.Append(kvp.Key).Append('=').AppendLine(kvp.Value);
                }
            }

            return s.ToString();
        }

Usage Example

コード例 #1
0
        public void SettingsToString()
        {
            string configuration = new System.Text.StringBuilder()
                .AppendLine("[DEFAULT]")
                .AppendLine("CONNECTIONTYPE=initiator")
                .AppendLine("BEGINSTRING=FIX.4.0")
                .AppendLine()
                .AppendLine("[SESSION]")
                .AppendLine("BEGINSTRING=FIX.4.2")
                .AppendLine("SENDERCOMPID=ISLD")
                .AppendLine("TARGETCOMPID=TW")
                .AppendLine("VALUE=1")
                .AppendLine()
                .AppendLine("[SESSION]")
                .AppendLine("BEGINSTRING=FIX.4.1")
                .AppendLine("SENDERCOMPID=ISLD")
                .AppendLine("TARGETCOMPID=WT")
                .AppendLine("VALUE=2")
                .ToString();
            SessionSettings settings = new SessionSettings(new System.IO.StringReader(configuration));

            Assert.That(settings.ToString(), Is.EqualTo(configuration));
        }