Exemple #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);
                }
            }
        }
Exemple #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);
                        }
                    }
                }
            }
        }
Exemple #3
0
        private FixDxEnumeration CloneEnumeration(FixDxEnumeration source)
        {
            FixDxEnumeration result = new FixDxEnumeration(source.Name);

            foreach (FixDxEnumerator dxEnumerator in source.Enumerators)
            {
                result.Enumerators.Add(new FixDxEnumerator(dxEnumerator.Value, dxEnumerator.Description));
            }

            return(result);
        }
Exemple #4
0
 /// <summary>
 /// The PopulateEnums method populates the enumerations section
 /// of the supplied VFX dictionary with all of the enumerations
 /// that are defined in the supplied XML dictionary.
 /// </summary>
 /// <param name="source">
 /// The source dictionary for the enumeration elements.
 /// </param>
 /// <param name="target">
 /// The target dictionary for the converted elements.
 /// </param>
 private static void PopulateEnums(XmlDictionary source, FixDictionary target)
 {
     foreach (XmlFixDxEnumeration src in source.Enums.Entries)
     {
         FixDxEnumeration dst = new FixDxEnumeration(src.Name);
         foreach (object element in src.Enumerators)
         {
             if (element is XmlFixDxEnumerator)
             {
                 XmlFixDxEnumerator srcEnum = element as XmlFixDxEnumerator;
                 FixDxEnumerator    dstEnum = new FixDxEnumerator(srcEnum.value, srcEnum.Description);
                 dst.Enumerators.Add(dstEnum);
             }
         }
         target.AddEnumeration(dst);
     }
 }
Exemple #5
0
        /// <summary>
        /// The AddEnumeration method adds an instance of an
        /// enumeration to the dictionary. Enumerations are keyed
        /// by their unique identifier, so if the enumeration that
        /// is being added collides with one that is already in the
        /// dictionary, the operation will fail.
        /// </summary>
        /// <param name="enumeration">
        /// The enumeration to be added to the dictionary.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if the enumeration's name is null or blank or
        /// if there is already an enumeration with the specified
        /// name in the dictionary.
        /// </exception>
        public void AddEnumeration(FixDxEnumeration enumeration)
        {
            if (!string.IsNullOrEmpty(enumeration.Name))
            {
                if (!_mapEnumerations.ContainsKey(enumeration.Name))
                {
                    _mapEnumerations.Add(enumeration.Name, enumeration);
                }
                else
                {
                    string error = string.Format("Dictionary already contains an enumeration named {0}.", enumeration.Name);
                    throw new ArgumentException(error);
                }

                _enmElements.Add(enumeration);
            }
            else
            {
                throw new ArgumentException("The enumeration's name is not specified.");
            }
        }
Exemple #6
0
        private FixDxEnumeration CloneEnumeration(FixDxEnumeration source)
        {
            FixDxEnumeration result = new FixDxEnumeration(source.Name);
            foreach (FixDxEnumerator dxEnumerator in source.Enumerators)
            {
                result.Enumerators.Add(new FixDxEnumerator(dxEnumerator.Value, dxEnumerator.Description));
            }

            return result;
        }
Exemple #7
0
        /// <summary>
        /// The AddEnumeration method adds an instance of an
        /// enumeration to the dictionary. Enumerations are keyed
        /// by their unique identifier, so if the enumeration that
        /// is being added collides with one that is already in the
        /// dictionary, the operation will fail.
        /// </summary>
        /// <param name="enumeration">
        /// The enumeration to be added to the dictionary.
        /// </param>
        /// <exception cref="ArgumentException">
        /// Thrown if the enumeration's name is null or blank or
        /// if there is already an enumeration with the specified
        /// name in the dictionary.
        /// </exception>
        public void AddEnumeration(FixDxEnumeration enumeration)
        {
            if (!string.IsNullOrEmpty(enumeration.Name))
            {
                if (!_mapEnumerations.ContainsKey(enumeration.Name))
                {
                    _mapEnumerations.Add(enumeration.Name, enumeration);
                }
                else
                {
                    string error = string.Format("Dictionary already contains an enumeration named {0}.", enumeration.Name);
                    throw new ArgumentException(error);
                }

                _enmElements.Add(enumeration);
            }
            else
            {
                throw new ArgumentException("The enumeration's name is not specified.");
            }
        }
Exemple #8
0
 /// <summary>
 /// The PopulateEnums method populates the enumerations section
 /// of the supplied VFX dictionary with all of the enumerations
 /// that are defined in the supplied XML dictionary.
 /// </summary>
 /// <param name="source">
 /// The source dictionary for the enumeration elements.
 /// </param>
 /// <param name="target">
 /// The target dictionary for the converted elements.
 /// </param>
 private static void PopulateEnums(XmlDictionary source, FixDictionary target)
 {
     foreach (XmlFixDxEnumeration src in source.Enums.Entries)
     {
         FixDxEnumeration dst = new FixDxEnumeration(src.Name);
         foreach (object element in src.Enumerators)
         {
             if (element is XmlFixDxEnumerator)
             {
                 XmlFixDxEnumerator srcEnum = element as XmlFixDxEnumerator;
                 FixDxEnumerator dstEnum = new FixDxEnumerator(srcEnum.value, srcEnum.Description);
                 dst.Enumerators.Add(dstEnum);
             }
         }
         target.AddEnumeration(dst);
     }
 }