GetString() публичный Метод

public GetString ( string key, bool capitalize ) : String
key string
capitalize bool
Результат String
Пример #1
0
 public void SetGetString()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetString("STRINGKEY1", "STRINGVALUE1");
     d.SetString("STRINGKEY2", "stringvalue2");
     Assert.That(d.GetString("STRINGKEY1"), Is.EqualTo("STRINGVALUE1"));
     Assert.That(d.GetString("STRINGKEY2"), Is.EqualTo("stringvalue2"));
     Assert.That(d.GetString("STRINGKEY2", true), Is.EqualTo("STRINGVALUE2"));
     Assert.Throws<ConfigError>(delegate { d.GetString("STRINGKEY3"); });
 }
Пример #2
0
 public void SetGetString()
 {
     QuickFix.Dictionary d = new QuickFix.Dictionary();
     d.SetString("STRINGKEY1", "STRINGVALUE1");
     d.SetString("STRINGKEY2", "stringvalue2");
     Assert.That(d.GetString("STRINGKEY1"), Is.EqualTo("STRINGVALUE1"));
     Assert.That(d.GetString("STRINGKEY2"), Is.EqualTo("stringvalue2"));
     Assert.That(d.GetString("STRINGKEY2", true), Is.EqualTo("STRINGVALUE2"));
     Assert.Throws <ConfigError>(delegate { d.GetString("STRINGKEY3"); });
 }
Пример #3
0
        public void SetDouble()
        {
            // make sure that QF/n uses the invariant culture, no matter what the current culture is
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

            QuickFix.Dictionary d = new QuickFix.Dictionary();
            d.SetDouble("DOUBLEKEY1", 12.3);
            d.SetDouble("DOUBLEKEY2", 987362.987362);

            Assert.AreEqual("12.3", d.GetString("DOUBLEKEY1"));
            Assert.AreEqual("987362.987362", d.GetString("DOUBLEKEY2"));
        }
Пример #4
0
        public void SetDouble()
        {
            // make sure that QF/n uses the invariant culture, no matter what the current culture is
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("fr-FR");

            QuickFix.Dictionary d = new QuickFix.Dictionary();
            d.SetDouble("DOUBLEKEY1", 12.3);
            d.SetDouble("DOUBLEKEY2", 987362.987362);

            Assert.AreEqual("12.3", d.GetString("DOUBLEKEY1"));
            Assert.AreEqual("987362.987362", d.GetString("DOUBLEKEY2"));
        }
Пример #5
0
        public void Merge()
        {
            QuickFix.Dictionary first = new QuickFix.Dictionary();
            first.SetString("FIRSTKEY", "FIRSTVALUE");
            first.SetString("THIRDKEY", "FIRST");

            QuickFix.Dictionary second = new QuickFix.Dictionary();
            second.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("THIRDKEY", "SECOND");

            first.Merge(second);
            Assert.That(first.GetString("FIRSTKEY"), Is.EqualTo("FIRSTVALUE"));
            Assert.That(first.GetString("SECONDKEY"), Is.EqualTo("SECONDVALUE"));
            Assert.That(first.GetString("THIRDKEY"), Is.EqualTo("FIRST"));
        }
Пример #6
0
        public void Merge()
        {
            QuickFix.Dictionary first = new QuickFix.Dictionary();
            first.SetString("FIRSTKEY", "FIRSTVALUE");
            first.SetString("THIRDKEY", "FIRST");

            QuickFix.Dictionary second = new QuickFix.Dictionary();
            second.SetString("SECONDKEY", "SECONDVALUE");
            second.SetString("THIRDKEY", "SECOND");

            first.Merge(second);
            Assert.That(first.GetString("FIRSTKEY"), Is.EqualTo("FIRSTVALUE"));
            Assert.That(first.GetString("SECONDKEY"), Is.EqualTo("SECONDVALUE"));
            Assert.That(first.GetString("THIRDKEY"), Is.EqualTo("FIRST"));
        }
Пример #7
0
        public AbstractInitiator(IApplication app, IMessageStoreFactory storeFactory, SessionSettings settings, ILogFactory logFactory, IMessageFactory messageFactory)
        {
            settings_ = settings;

            HashSet <SessionID> definedSessions = settings.GetSessions();

            if (0 == definedSessions.Count)
            {
                throw new ConfigError("No sessions defined");
            }

            SessionFactory factory = new SessionFactory(app, storeFactory, logFactory, messageFactory);

            foreach (SessionID sessionID in definedSessions)
            {
                Dictionary dict = settings.Get(sessionID);
                if ("initiator".Equals(dict.GetString(SessionSettings.CONNECTION_TYPE)))
                {
                    sessionIDs_.Add(sessionID);
                    sessions_[sessionID] = factory.Create(sessionID, dict);
                    SetDisconnected(sessionID);
                }
            }

            if (0 == sessions_.Count)
            {
                throw new ConfigError("No sessions defined for initiator");
            }
        }
Пример #8
0
        protected void ProcessFixTDataDictionaries(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
        {
            provider.AddTransportDataDictionary(sessionID.BeginString, createDataDictionary(sessionID, settings, SessionSettings.TRANSPORT_DATA_DICTIONARY, sessionID.BeginString));

            foreach (KeyValuePair <string, string> setting in settings)
            {
                if (setting.Key.StartsWith(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    if (setting.Key.Equals(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                    {
                        Fields.ApplVerID applVerId       = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, SessionSettings.APP_DATA_DICTIONARY, sessionID.BeginString);
                        provider.AddApplicationDataDictionary(applVerId.Obj, dd);
                    }
                    else
                    {
                        int offset = setting.Key.IndexOf(".");
                        if (offset == -1)
                        {
                            throw new System.ArgumentException(string.Format("Malformed {0} : {1}", SessionSettings.APP_DATA_DICTIONARY, setting.Key));
                        }

                        string beginStringQualifier      = setting.Key.Substring(offset);
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, setting.Key, beginStringQualifier);
                        provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Obj, dd);
                    }
                }
            }
        }
Пример #9
0
        private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(Dictionary dict)
        {
            int            port           = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT));
            SocketSettings socketSettings = new SocketSettings();

            IPEndPoint socketEndPoint;

            if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST))
            {
                string      host  = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST);
                IPAddress[] addrs = Dns.GetHostAddresses(host);
                socketEndPoint = new IPEndPoint(addrs[0], port);
                // Set hostname (if it is not already configured)
                socketSettings.ServerCommonName = socketSettings.ServerCommonName ?? host;
            }
            else
            {
                socketEndPoint = new IPEndPoint(IPAddress.Any, port);
            }

            socketSettings.Configure(dict);


            AcceptorSocketDescriptor descriptor;

            if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor))
            {
                descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict);
                socketDescriptorForAddress_[socketEndPoint] = descriptor;
            }

            return(descriptor);
        }
Пример #10
0
        public void Start()
        {
            if (_disposed)
            {
                throw new System.ObjectDisposedException(this.GetType().Name);
            }

            // create all sessions
            SessionFactory factory = new SessionFactory(_app, _storeFactory, _logFactory, _msgFactory);

            foreach (SessionID sessionID in _settings.GetSessions())
            {
                Dictionary dict           = _settings.Get(sessionID);
                string     connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE);

                if ("initiator".Equals(connectionType))
                {
                    sessionIDs_.Add(sessionID);
                    sessions_[sessionID] = factory.Create(sessionID, dict);
                    SetDisconnected(sessionID);
                }
            }

            if (0 == sessions_.Count)
            {
                throw new ConfigError("No sessions defined for initiator");
            }

            // start it up
            isStopped_ = false;
            OnConfigure(_settings);
            thread_ = new Thread(new ThreadStart(OnStart));
            thread_.Start();
        }
Пример #11
0
        private void Validate(QuickFix.Dictionary dictionary)
        {
            string beginString = dictionary.GetString(SessionSettings.BEGINSTRING);

            if (beginString != Values.BeginString_FIX40 &&
                beginString != Values.BeginString_FIX41 &&
                beginString != Values.BeginString_FIX42 &&
                beginString != Values.BeginString_FIX43 &&
                beginString != Values.BeginString_FIX44 &&
                beginString != Values.BeginString_FIXT11)
            {
                throw new ConfigError(SessionSettings.BEGINSTRING + " (" + beginString + ") must be FIX.4.0 to FIX.4.4 or FIXT.1.1");
            }

            string connectionType = dictionary.GetString(SessionSettings.CONNECTION_TYPE);

            if (!"initiator".Equals(connectionType) && !"acceptor".Equals(connectionType))
            {
                throw new ConfigError(SessionSettings.CONNECTION_TYPE + " must be 'initiator' or 'acceptor'");
            }
        }
Пример #12
0
        private void LoadXml()
        {
            xmlDoc = new XmlDocument();
            xmlDoc.Load("Scenarios.xml");

            XDocument xDoc = XDocument.Load("Scenarios.xml");

            // QFN Default Session Settings
            //defaults = new Dictionary();
            //IEnumerable<XElement> xDefault = xDoc.Root.Element("QFNSessionSettings").Element("Default").Descendants();
            //foreach (XElement xe in xDefault)
            //{
            //    defaults.SetString(xe.Name.ToString(), xe.Value);
            //}

            // QFN Specific Session Settings
            session = new Dictionary();
            IEnumerable <XElement> xSession = xDoc.Root.Element("QFNSessionSettings").Element("Session").Descendants();

            foreach (XElement xe in xSession)
            {
                session.SetString(xe.Name.ToString(), xe.Value);
            }

            SessionID sessionID = new SessionID(session.GetString("BeginString"), session.GetString("SenderCompID"), session.GetString("TargetCompID"));

            ConfigurationSingleton.Instance.RemovaAllQFNSettings();
            //ConfigurationSingleton.Instance.AddQFNSettings(defaults);
            ConfigurationSingleton.Instance.AddQFNSettings(sessionID, session);
            ConfigurationSingleton.Instance.SetTagsToIgnore(xDoc.Root.Element("TagsToIgnore").Value);

            sc      = new List <string>();
            scNodes = new List <XmlNode>();
            foreach (XmlNode xNode in xmlDoc.GetElementsByTagName("Scenario"))
            {
                sc.Add(xNode.Attributes["Name"].Value);
                scNodes.Add(xNode);
            }
        }
Пример #13
0
 /// <summary>
 /// Create session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session</param>
 /// <param name="dict">config settings for new session</param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 private bool CreateSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (sync_)
         {
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return(true);
     }
     return(false);
 }
Пример #14
0
 /// <summary>
 /// Create session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 private bool CreateSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (GdaxPrototyping.Common.Core.Threading.TThreadingHelpers.MainLockable)
         {
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return(true);
     }
     return(false);
 }
Пример #15
0
 /// <summary>
 /// Create session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session</param>
 /// <param name="dict">config settings for new session</param>
 /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns>
 private bool CreateSession(SessionID sessionID, Dictionary dict)
 {
     if (!sessions_.ContainsKey(sessionID))
     {
         string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE);
         if ("acceptor" == connectionType)
         {
             AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(dict);
             Session session = sessionFactory_.Create(sessionID, dict);
             descriptor.AcceptSession(session);
             sessions_[sessionID] = session;
             return(true);
         }
     }
     return(false);
 }
Пример #16
0
 /// <summary>
 /// Add new session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 public bool AddSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (sync_)
         {
             if (!_settings.Has(sessionID))  // session won't be in settings if ad-hoc creation after startup
             {
                 _settings.Set(sessionID, dict);
             }
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return(true);
     }
     return(false);
 }
Пример #17
0
        /// <summary>
        /// Create session, either at start-up or as an ad-hoc operation
        /// </summary>
        /// <param name="sessionID">ID of new session</param>
        /// <param name="dict">config settings for new session</param>
        /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns>
        private bool CreateSession(SessionID sessionID, Dictionary dict)
        {
            if (!sessions_.ContainsKey(sessionID))
            {
                string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE);
                if ("acceptor" == connectionType)
                {
                    AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(dict);
                    Session session = sessionFactory_.Create(sessionID, dict);

                    // start descriptor if it was just created and if acceptor is already started
                    if (isStarted_ && !_disposed && !descriptor.SocketReactor.IsStarted)
                    {
                        descriptor.SocketReactor.Start();
                    }

                    descriptor.AcceptSession(session);
                    sessions_[sessionID] = session;
                    return(true);
                }
            }
            return(false);
        }
Пример #18
0
        protected void ProcessFixTDataDictionaries(SessionID sessionID, Dictionary settings, DataDictionaryProvider provider)
        {
            provider.AddTransportDataDictionary(sessionID.BeginString, createDataDictionary(sessionID, settings, SessionSettings.TRANSPORT_DATA_DICTIONARY, sessionID.BeginString));

            foreach (KeyValuePair<string, string> setting in settings)
            {
                if (setting.Key.StartsWith(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                {
                    if (setting.Key.Equals(SessionSettings.APP_DATA_DICTIONARY, System.StringComparison.CurrentCultureIgnoreCase))
                    {
                        Fields.ApplVerID applVerId = Message.GetApplVerID(settings.GetString(SessionSettings.DEFAULT_APPLVERID));
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, SessionSettings.APP_DATA_DICTIONARY, sessionID.BeginString);
                        provider.AddApplicationDataDictionary(applVerId.Obj, dd);
                    }
                    else
                    {
                        int offset = setting.Key.IndexOf(".");
                        if (offset == -1)
                            throw new System.ArgumentException(string.Format("Malformed {0} : {1}", SessionSettings.APP_DATA_DICTIONARY, setting.Key));

                        string beginStringQualifier = setting.Key.Substring(offset);
                        DataDictionary.DataDictionary dd = createDataDictionary(sessionID, settings, setting.Key, beginStringQualifier);
                        provider.AddApplicationDataDictionary(Message.GetApplVerID(beginStringQualifier).Obj, dd);
                    }
                }
            }
        }
Пример #19
0
 /// <summary>
 /// Create session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an acceptor</returns>
 private bool CreateSession(SessionID sessionID, Dictionary dict)
 {
     if (!sessions_.ContainsKey(sessionID))
     {
         string connectionType = dict.GetString(SessionSettings.CONNECTION_TYPE);
         if ("acceptor" == connectionType)
         {
             AcceptorSocketDescriptor descriptor = GetAcceptorSocketDescriptor(dict);
             Session session = sessionFactory_.Create(sessionID, dict);
             descriptor.AcceptSession(session);
             sessions_[sessionID] = session;
             return true;
         }
     }
     return false;
 }
Пример #20
0
        private AcceptorSocketDescriptor GetAcceptorSocketDescriptor(Dictionary dict)
        {
            int port = System.Convert.ToInt32(dict.GetLong(SessionSettings.SOCKET_ACCEPT_PORT));
            SocketSettings socketSettings = new SocketSettings();

            IPEndPoint socketEndPoint;
            if (dict.Has(SessionSettings.SOCKET_ACCEPT_HOST))
            {
                string host = dict.GetString(SessionSettings.SOCKET_ACCEPT_HOST);                
                IPAddress[] addrs = Dns.GetHostAddresses(host);
                socketEndPoint = new IPEndPoint(addrs[0], port);
                // Set hostname (if it is not already configured)
                socketSettings.ServerCommonName = socketSettings.ServerCommonName ?? host;
            }
            else
            {
                socketEndPoint = new IPEndPoint(IPAddress.Any, port);
            }

            socketSettings.Configure(dict);
            

            AcceptorSocketDescriptor descriptor;
            if (!socketDescriptorForAddress_.TryGetValue(socketEndPoint, out descriptor))
            {
                descriptor = new AcceptorSocketDescriptor(socketEndPoint, socketSettings, dict);
                socketDescriptorForAddress_[socketEndPoint] = descriptor;
            }

            return descriptor;
        }
Пример #21
0
 /// <summary>
 /// Create session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 private bool CreateSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (sync_)
         {
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return true;
     }
     return false;
 }
Пример #22
0
 /// <summary>
 /// Add new session, either at start-up or as an ad-hoc operation
 /// </summary>
 /// <param name="sessionID">ID of new session<param>
 /// <param name="dict">config settings for new session</param></param>
 /// <returns>true if session added successfully, false if session already exists or is not an initiator</returns>
 public bool AddSession(SessionID sessionID, Dictionary dict)
 {
     if (dict.GetString(SessionSettings.CONNECTION_TYPE) == "initiator" && !sessionIDs_.Contains(sessionID))
     {
         Session session = sessionFactory_.Create(sessionID, dict);
         lock (sync_)
         {
             if (!_settings.Has(sessionID))  // session won't be in settings if ad-hoc creation after startup
                 _settings.Set(sessionID, dict);
             sessionIDs_.Add(sessionID);
             sessions_[sessionID] = session;
             SetDisconnected(sessionID);
         }
         return true;
     }
     return false;
 }
Пример #23
0
        private DataDictionary.DataDictionary LoadDataDictionaryFromStream(Dictionary settings, Stream dictionaryStream)
        {
            DataDictionary.DataDictionary dd;
            string path = settings.GetString(SessionSettings.DATA_DICTIONARY_STREAM);

            if (!dictionariesByPath_.TryGetValue(path, out dd))
            {
                dd = new DataDictionary.DataDictionary(dictionaryStream);
                dictionariesByPath_[path] = dd;
            }

            DataDictionary.DataDictionary ddCopy = new DataDictionary.DataDictionary(dd);

            if (settings.Has(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER))
                ddCopy.CheckFieldsOutOfOrder = settings.GetBool(SessionSettings.VALIDATE_FIELDS_OUT_OF_ORDER);
            if (settings.Has(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES))
                ddCopy.CheckFieldsHaveValues = settings.GetBool(SessionSettings.VALIDATE_FIELDS_HAVE_VALUES);
            if (settings.Has(SessionSettings.VALIDATE_USER_DEFINED_FIELDS))
                ddCopy.CheckUserDefinedFields = settings.GetBool(SessionSettings.VALIDATE_USER_DEFINED_FIELDS);

            return ddCopy;
        }