Get() public method

public Get ( string sectionName ) : LinkedList
sectionName string
return LinkedList
Beispiel #1
0
        public void Load()
        {
            string configuration = @"[FOO]
bar=24
baz=moo
[OREN]
Nero=TW
#Nero=IGNOREME
# this is a comment
#[OREN]
#Nero=IGNOREME
[OREN]
ISLD=Nero
STUFF=./\:
[NERO]
WINDIR=D:\This Is\A-Directory\Connamara\
WINFILE=D:\Program Files\Tomcat 4.1\webapps\mgatny\WEB-INF\connamara.cfg
UNIXDIR=/home/mgatny/This Is/A Directory/ok/
stripspace=last spaces stripped   
#Nero=IGNOREME
EqualsInValue=We can have '=' in the value
";
            Settings settings = new Settings(new System.IO.StringReader(configuration));

            LinkedList<QuickFix.Dictionary> foo = settings.Get("FOO");
            Assert.That(foo.Count, Is.EqualTo(1));
            Assert.That(foo.First.Value.GetLong("bar"), Is.EqualTo(24));
            Assert.That(foo.First.Value.GetString("baz"), Is.EqualTo("moo"));
            Assert.That(foo.First.Value.GetString("baz"), Is.EqualTo("moo"));
            Assert.That(foo.First.Value.Count, Is.EqualTo(2));

            LinkedList<QuickFix.Dictionary> oren = settings.Get("OREN");
            Assert.That(oren.Count, Is.EqualTo(2));            
            Assert.That(oren.First.Value.Count, Is.EqualTo(1));
            Assert.That(oren.First.Value.GetString("Nero"), Is.EqualTo("TW"));
            oren.RemoveFirst();
            Assert.That(oren.First.Value.Count, Is.EqualTo(2));
            Assert.That(oren.First.Value.GetString("ISLD"), Is.EqualTo("Nero"));
            Assert.That(oren.First.Value.GetString("STUFF"), Is.EqualTo("./\\:"));

            LinkedList<QuickFix.Dictionary> nero = settings.Get("NERO");
            Assert.That(nero.Count, Is.EqualTo(1));
            Assert.That(nero.First.Value.Count, Is.EqualTo(5));
            Assert.That(nero.First.Value.GetString("WINDIR"), Is.EqualTo("D:\\This Is\\A-Directory\\Connamara\\"));
            Assert.That(nero.First.Value.GetString("UNIXDIR"), Is.EqualTo("/home/mgatny/This Is/A Directory/ok/"));
            Assert.That(nero.First.Value.GetString("WINFILE"), Is.EqualTo("D:\\Program Files\\Tomcat 4.1\\webapps\\mgatny\\WEB-INF\\connamara.cfg"));
            Assert.That(nero.First.Value.GetString("stripspace"), Is.EqualTo("last spaces stripped"));
            Assert.That(nero.First.Value.GetString("EqualsInValue"), Is.EqualTo("We can have '=' in the value"));
        }
Beispiel #2
0
        public void Load()
        {
            string configuration = new System.Text.StringBuilder()
                .AppendLine("[FOO]").AppendLine("bar=24").AppendLine("baz=moo")
                .AppendLine("[OREN]").AppendLine("Nero=TW").AppendLine("#Nero=IGNOREME")
                .AppendLine("# this is a comment")
                .AppendLine("#[OREN]").AppendLine("#Nero=IGNOREME")
                .AppendLine("[OREN]").AppendLine("ISLD=Nero").AppendLine("STUFF=./\\:")
                .AppendLine("[NERO]").AppendLine("WINDIR=D:\\This Is\\A-Directory\\Connamara\\")
                .AppendLine("WINFILE=D:\\Program Files\\Tomcat 4.1\\webapps\\mgatny\\WEB-INF\\connamara.cfg")
                .AppendLine("UNIXDIR=/home/mgatny/This Is/A Directory/ok/")
                .AppendLine("stripspace=last spaces stripped   ")
                .AppendLine("#Nero=IGNOREME")
                .ToString();
            Settings settings = new Settings(new System.IO.StringReader(configuration));

            LinkedList<QuickFix.Dictionary> foo = settings.Get("FOO");
            Assert.That(foo.Count, Is.EqualTo(1));
            Assert.That(foo.First.Value.GetLong("bar"), Is.EqualTo(24));
            Assert.That(foo.First.Value.GetString("baz"), Is.EqualTo("moo"));
            Assert.That(foo.First.Value.GetString("baz"), Is.EqualTo("moo"));
            Assert.That(foo.First.Value.Count, Is.EqualTo(2));

            LinkedList<QuickFix.Dictionary> oren = settings.Get("OREN");
            Assert.That(oren.Count, Is.EqualTo(2));
            Assert.That(oren.First.Value.Count, Is.EqualTo(1));
            Assert.That(oren.First.Value.GetString("Nero"), Is.EqualTo("TW"));
            oren.RemoveFirst();
            Assert.That(oren.First.Value.Count, Is.EqualTo(2));
            Assert.That(oren.First.Value.GetString("ISLD"), Is.EqualTo("Nero"));
            Assert.That(oren.First.Value.GetString("STUFF"), Is.EqualTo("./\\:"));

            LinkedList<QuickFix.Dictionary> nero = settings.Get("NERO");
            Assert.That(nero.Count, Is.EqualTo(1));
            Assert.That(nero.First.Value.Count, Is.EqualTo(4));
            Assert.That(nero.First.Value.GetString("WINDIR"), Is.EqualTo("D:\\This Is\\A-Directory\\Connamara\\"));
            Assert.That(nero.First.Value.GetString("UNIXDIR"), Is.EqualTo("/home/mgatny/This Is/A Directory/ok/"));
            Assert.That(nero.First.Value.GetString("WINFILE"), Is.EqualTo("D:\\Program Files\\Tomcat 4.1\\webapps\\mgatny\\WEB-INF\\connamara.cfg"));
            Assert.That(nero.First.Value.GetString("stripspace"), Is.EqualTo("last spaces stripped"));
        }
Beispiel #3
0
        public void CaseInsensitiveSectionName()
        {
            string configuration = @"[foo]
one=uno
two=dos
[bar]
what=huh";
            Settings settings = new Settings(new System.IO.StringReader(configuration));

            LinkedList<QuickFix.Dictionary> byLower = settings.Get("foo");
            Assert.AreEqual(1, byLower.Count);
            Assert.AreEqual(2, byLower.First.Value.Count);
            Assert.AreEqual("uno", byLower.First.Value.GetString("one"));
            Assert.AreEqual("dos", byLower.First.Value.GetString("two"));

            // too lazy to write a QuickFix.Dictionary#Equals method (which would only be used by this test)
            LinkedList<QuickFix.Dictionary> byUpper = settings.Get("FOO");
            Assert.AreEqual(byLower.Count, byUpper.Count);
            Assert.AreEqual(byLower.First.Value.Count, byUpper.First.Value.Count);
            Assert.AreEqual(byUpper.First.Value.GetString("one"), byUpper.First.Value.GetString("one"));
            Assert.AreEqual(byUpper.First.Value.GetString("two"), byUpper.First.Value.GetString("two"));
        }
Beispiel #4
0
        protected void Load(TextReader conf)
        {
            Settings settings = new Settings(conf);

            //---- load the DEFAULT section
            LinkedList<QuickFix.Dictionary> section = settings.Get("DEFAULT");
            QuickFix.Dictionary def = new QuickFix.Dictionary();
            if (section.Count > 0)
                def = section.First.Value;
            Set(def);

            //---- load each SESSION section
            section = settings.Get("SESSION");
            foreach (QuickFix.Dictionary dict in section)
            {
                dict.Merge(def);

                string sessionQualifier = SessionID.NOT_SET;
                string senderSubID = SessionID.NOT_SET;
                string senderLocID = SessionID.NOT_SET;
                string targetSubID = SessionID.NOT_SET;
                string targetLocID = SessionID.NOT_SET;

                if (dict.Has(SESSION_QUALIFIER))
                    sessionQualifier = dict.GetString(SESSION_QUALIFIER);
                if (dict.Has(SENDERSUBID))
                    senderSubID = dict.GetString(SENDERSUBID);
                if (dict.Has(SENDERLOCID))
                    senderLocID = dict.GetString(SENDERLOCID);
                if (dict.Has(TARGETSUBID))
                    targetSubID = dict.GetString(TARGETSUBID);
                if (dict.Has(TARGETLOCID))
                    targetLocID = dict.GetString(TARGETLOCID);
                SessionID sessionID = new SessionID(dict.GetString(BEGINSTRING), dict.GetString(SENDERCOMPID), senderSubID, senderLocID, dict.GetString(TARGETCOMPID), targetSubID, targetLocID, sessionQualifier);
                Set(sessionID, dict);
            }
        }