Esempio n. 1
0
        /// <summary>
        /// The ExportFields method is invoked to convert all of
        /// the field elements in an instance of a VersaFix data
        /// dictionary into corresponding entries in an instance
        /// of an XML representation of a QuickFix dictionary.
        /// </summary>
        /// <param name="src">
        /// The source dictionary for the field definitions.
        /// </param>
        /// <param name="dst">
        /// The target dictionary for the field definitions.
        /// </param>
        private void ExportFields(FixDictionary src, XmlQfxDictionary dst)
        {
            foreach (IFixDxElement dxElement in src.Fields)
            {
                FixDxField dxField = dxElement as FixDxField;
                if (dxField != null)
                {
                    XmlQfxField xmlField = new XmlQfxField();
                    xmlField.Name   = dxField.Name;
                    xmlField.Number = dxField.Tag.ToString();
                    xmlField.Type   = dxField.Type;

                    // REC: QuickFix stores the enumerators for each
                    // field inside the field definition, so we have
                    // to check if there is an enumeration associated
                    // with this field and add the enumeration to the
                    // field definition if one is found:
                    FixDxEnumeration dxEnum = src.Enums.GetElement(dxField.Name) as FixDxEnumeration;
                    if (dxEnum != null)
                    {
                        foreach (FixDxEnumerator dxEnumerator in dxEnum.Enumerators)
                        {
                            XmlQfxFieldEnumerator xmlEnumerator = new XmlQfxFieldEnumerator();
                            xmlEnumerator.Enum        = dxEnumerator.Value;
                            xmlEnumerator.Description = dxEnumerator.Description;
                            xmlField.Enumeration.Add(xmlEnumerator);
                        }
                    }

                    dst.Fields.Add(xmlField);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// The PopulateEnums method iterates over all of the fields that
        /// are defined in a QuickFix dictionary and converts their inline
        /// enumeration definitions into discreet enumeration instances in
        /// the target VersaFix dictionary instance.
        /// </summary>
        /// <param name="src">
        /// The XML representation of a QuickFix dictionary that the
        /// enumerations are to be read from.
        /// </param>
        /// <param name="dst">
        /// The VersaFix dictionary that the enumerations are to be
        /// written out to.
        /// </param>
        private void PopulateEnums(XmlQfxDictionary src, FixDictionary dst)
        {
            foreach (object field in src.Fields)
            {
                XmlQfxField xmlField = field as XmlQfxField;
                if (xmlField != null)
                {
                    if (xmlField.Enumeration.Count > 0)
                    {
                        string xmlName = xmlField.Name;
                        if (!string.IsNullOrEmpty(xmlName))
                        {
                            FixDxEnumeration dxEnum = new FixDxEnumeration(xmlName);
                            foreach (object enumerator in xmlField.Enumeration)
                            {
                                XmlQfxFieldEnumerator xmlEnumerator = enumerator as XmlQfxFieldEnumerator;
                                if (xmlEnumerator != null)
                                {
                                    dxEnum.Enumerators.Add(new FixDxEnumerator(xmlEnumerator.Enum, xmlEnumerator.Description));
                                }
                            }

                            dst.Enums.Add(dxEnum);
                        }
                    }
                }
            }
        }