Example #1
0
        /// <summary>
        /// The PopulateBlocks method populates the blocks section
        /// of the supplied XML dictionary with the corresponding
        /// elements from the supplied FixDictionary instance.
        /// </summary>
        /// <param name="xmlDictionary">
        /// The XmlDictionary instance that is to be populated.
        /// </param>
        /// <param name="fixDictionary">
        /// The FixDictionary instance that is the source of the
        /// elements the XmlDictionary is to be populated with.
        /// </param>
        private static void PopulateBlocks(XmlDictionary xmlDictionary, FixDictionary fixDictionary)
        {
            foreach (FixDxBlock dxBlock in fixDictionary.Blocks)
            {
                XmlFixDxBlock xmlBlock = new XmlFixDxBlock();
                xmlBlock.Name  = dxBlock.Name;
                xmlBlock.Type  = dxBlock.Type.ToString();
                xmlBlock.Field = dxBlock.Field;

                xmlBlock.Elements = TranslateElements(dxBlock.Elements).Elements;
                xmlDictionary.Blocks.Entries.Add(xmlBlock);
            }
        }
Example #2
0
        /// <summary>
        /// The PopulateMessages method populates the message section
        /// of the supplied VFX dictionary with all message definitions
        /// that are found in the supplied XML dictionary.
        /// </summary>
        /// <param name="source">
        /// The source dictionary for the message elements.
        /// </param>
        /// <param name="target">
        /// The target dictionary for the converted elements.
        /// </param>
        private static void PopulateMessages(XmlDictionary source, FixDictionary target)
        {
            foreach (XmlFixDxMessage src in source.Messages.Entries)
            {
                FixDxMessage dst = new FixDxMessage(src.MsgType, src.Name, src.MsgCategory);
                foreach (IFixDxElement dxElement in TranslateElements(src.Elements))
                {
                    dst.Elements.Add(dxElement);
                }

                target.AddMessage(dst);
            }
        }
Example #3
0
        /// <summary>
        /// The PopulateMetadata method populates the metadata properties
        /// in an XmlDictionary instance with the corresponding entries from
        /// an instance of a VersaFix dictionary.
        /// </summary>
        /// <param name="source">
        /// The source dictionary for the elements being copied.
        /// </param>
        /// <param name="target">
        /// The target dictionary for the elements to be copied into.
        /// </param>
        private static void PopulateMetadata(FixDictionary source, XmlDictionary target)
        {
            foreach (string key in source.Properties.Keys)
            {
                // REC: Construct an XML representation of the property
                // and add it to the target dictionary:
                XmlFixDxProperty xmlProperty = new XmlFixDxProperty();
                xmlProperty.Name  = key;
                xmlProperty.Value = source.Properties[key];

                target.Properties.Elements.Add(xmlProperty);
            }
        }
Example #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);
     }
 }
Example #5
0
        /// <summary>
        /// The PopulateBlocks method populates the blocks section
        /// of the supplied VFX dictionary with all of the blocks
        /// that are defined in the supplied XML dictionary.
        /// </summary>
        /// <param name="source">
        /// The source dictionary for the block elements.
        /// </param>
        /// <param name="target">
        /// The target dictionary for the converted elements.
        /// </param>
        private static void PopulateBlocks(XmlDictionary source, FixDictionary target)
        {
            foreach (XmlFixDxBlock src in source.Blocks.Entries)
            {
                FixDxBlock dst = new FixDxBlock(src.Name);
                dst.Type     = (FixDxBlockTypes)Enum.Parse(typeof(FixDxBlockTypes), src.Type);
                dst.Field    = src.Field;
                dst.Category = src.Category;

                foreach (IFixDxElement element in TranslateElements(src.Elements))
                {
                    dst.Elements.Add(element);
                }

                target.AddBlock(dst);
            }
        }
Example #6
0
        /// <summary>
        /// The PopulateEnums method populates the enumerations
        /// section of the supplied XmlDictionary with all the
        /// enumerations from the supplied FixDictionary.
        /// </summary>
        /// <param name="xmlDictionary">
        /// The XmlDictionary instance being populated.
        /// </param>
        /// <param name="fixDictionary">
        /// The FixDictionary instance that is the source of the
        /// elements the XmlDictionary is to be populated with.
        /// </param>
        private static void PopulateEnums(XmlDictionary xmlDictionary, FixDictionary fixDictionary)
        {
            foreach (FixDxEnumeration dxEnumeration in fixDictionary.Enums)
            {
                XmlFixDxEnumeration xmlEnumeration = new XmlFixDxEnumeration();
                xmlEnumeration.Name = dxEnumeration.Name;
                foreach (FixDxEnumerator dxEnumerator in dxEnumeration.Enumerators)
                {
                    XmlFixDxEnumerator xmlEnumerator = new XmlFixDxEnumerator();
                    xmlEnumerator.value       = dxEnumerator.Value;
                    xmlEnumerator.Description = dxEnumerator.Description;
                    xmlEnumeration.Enumerators.Add(xmlEnumerator);
                }

                xmlDictionary.Enums.Entries.Add(xmlEnumeration);
            }
        }
Example #7
0
 /// <summary>
 /// The PopulateFields method populates the fields section
 /// of the supplied VFX dictionary with all of the fields
 /// that are found in the supplied XML dictionary.
 /// </summary>
 /// <param name="source">
 /// The source dictionary for the field elements.
 /// </param>
 /// <param name="target">
 /// The target dictionary for the converted elements.
 /// </param>
 private static void PopulateFields(XmlDictionary source, FixDictionary target)
 {
     foreach (XmlFixDxField src in source.Fields.Entries)
     {
         if (src.LengthField == null)
         {
             FixDxField dst = new FixDxField(src.Tag, src.Name, src.Type);
             dst.Enumeration = src.Enumeration;
             target.AddField(dst);
         }
         else
         {
             FixDxField dst = new FixDxField(src.Tag, src.Name, src.Type, src.LengthField);
             dst.Enumeration = src.Enumeration;
             target.AddField(dst);
         }
     }
 }
Example #8
0
        /// <summary>
        /// The PopulateTrailer method populates the trailer elements
        /// in an XmlDictionary instance with the elements from the
        /// source dictionary.
        /// </summary>
        /// <param name="xmlDictionary">
        /// The XmlDictionary instance that is being populated.
        /// </param>
        /// <param name="fixDictionary">
        /// The FixDictionary instance that is the source of the
        /// elements the XmlDictionary is to be populated with.
        /// </param>
        private static void PopulateTrailer(XmlDictionary xmlDictionary, FixDictionary fixDictionary)
        {
            // REC: Iterate over all of the trailer elements in the
            // source dictionary and convert them into instances of
            // their corresponding XML serializable types:
            foreach (IFixDxElement dxElement in fixDictionary.Trailer)
            {
                if (dxElement is FixDxFieldReference)
                {
                    FixDxFieldReference    fieldReference = dxElement as FixDxFieldReference;
                    XmlFixDxFieldReference xmlReference   = new XmlFixDxFieldReference();
                    xmlReference.Name     = fieldReference.Name;
                    xmlReference.Required = fieldReference.Required;

                    xmlDictionary.Trailer.Elements.Add(xmlReference);
                }
                else if (dxElement is FixDxBlockReference)
                {
                    FixDxBlockReference    blockReference = dxElement as FixDxBlockReference;
                    XmlFixDxBlockReference xmlReference   = new XmlFixDxBlockReference();
                    xmlReference.Name     = blockReference.Name;
                    xmlReference.Required = blockReference.Required;

                    xmlDictionary.Trailer.Elements.Add(xmlReference);
                }
                else if (dxElement is FixDxGroupReference)
                {
                    FixDxGroupReference    groupReference = dxElement as FixDxGroupReference;
                    XmlFixDxGroupReference xmlReference   = new XmlFixDxGroupReference();
                    xmlReference.Name     = groupReference.Name;
                    xmlReference.Required = groupReference.Required;

                    XmlFixDxElements xmlElements = TranslateElements(groupReference.Elements);
                    foreach (object xmlElement in xmlElements.Elements)
                    {
                        xmlReference.Elements.Add(xmlElement);
                    }

                    xmlDictionary.Trailer.Elements.Add(xmlReference);
                }
            }
        }
Example #9
0
        /// <summary>
        /// The PopulateMessages method populates the messages in
        /// an XmlDictionary instance with the message definitions
        /// from the source dictionary.
        /// </summary>
        /// <param name="xmlDictionary">
        /// The XmlDictionary instance that the message definitions
        /// are to be added to.
        /// </param>
        /// <param name="fixDictionary">
        /// The FixDictionary instance that is the source of the
        /// elements the XmlDictionary is to be populated with.
        /// </param>
        private static void PopulateMessages(XmlDictionary xmlDictionary, FixDictionary fixDictionary)
        {
            // REC: Iterate over all of the message definitions in the
            // source dictionary and convert them to XML serializable
            // representations for the serializable dictionary:
            foreach (FixDxMessage dxMessage in fixDictionary.Messages)
            {
                XmlFixDxMessage xmlMessage = new XmlFixDxMessage();
                xmlMessage.Name        = dxMessage.Name;
                xmlMessage.MsgType     = dxMessage.MsgType;
                xmlMessage.MsgCategory = dxMessage.MsgCategory;

                XmlFixDxElements xmlElements = TranslateElements(dxMessage.Elements);
                foreach (object xmlElement in xmlElements.Elements)
                {
                    xmlMessage.Elements.Add(xmlElement);
                }

                xmlDictionary.Messages.Entries.Add(xmlMessage);
            }
        }
Example #10
0
        /// <summary>
        /// The Import method deserializes an XML representation
        /// of a VersaFix dictionary from a stream and converts it
        /// into a corresponding instance of FixDictionary.
        /// </summary>
        /// <param name="stream">
        /// The stream that the XML data is to be read from.
        /// </param>
        /// <returns>
        /// The resulting instance of FixDictionary.
        /// </returns>
        public static FixDictionary Import(Stream stream)
        {
            XmlSerializer xs            = new XmlSerializer(typeof(XmlDictionary));
            XmlDictionary xmlDictionary = xs.Deserialize(stream) as XmlDictionary;

            // REC: Construct a new instance of a VersaFix dictionary
            // that the XML data will be converted into:
            FixDictionary result = new FixDictionary();

            // REC: Populate the VersaFix dictionary instance with all
            // of the elements that were read from the XML stream:
            PopulateMetadata(xmlDictionary, result);
            PopulateHeader(xmlDictionary, result);
            PopulateTrailer(xmlDictionary, result);
            PopulateMessages(xmlDictionary, result);
            PopulateFields(xmlDictionary, result);
            PopulateDataTypes(xmlDictionary, result);
            PopulateBlocks(xmlDictionary, result);
            PopulateEnums(xmlDictionary, result);

            return(result);
        }
Example #11
0
        /// <summary>
        /// The PopulateFields method populates the fields section
        /// of an XmlDictionary instance with the field definitions
        /// from the supplied FixDictionary instance.
        /// </summary>
        /// <param name="xmlDictionary">
        /// The XmlDictinary instance that the field definitions
        /// are to be added to.
        /// </param>
        /// <param name="fixDictionary">
        /// The FixDictionary instance that is the source of the
        /// elements the XmlDictionary is to be populated with.
        /// </param>
        private static void PopulateFields(XmlDictionary xmlDictionary, FixDictionary fixDictionary)
        {
            foreach (FixDxField dxField in fixDictionary.Fields)
            {
                XmlFixDxField xmlField = new XmlFixDxField();
                xmlField.Tag         = dxField.Tag;
                xmlField.Name        = dxField.Name;
                xmlField.Type        = dxField.Type;
                xmlField.Enumeration = dxField.Enumeration;

                if (dxField.LengthCoded == true)
                {
                    xmlField.LengthField = dxField.LengthField.ToString();
                }
                else
                {
                    xmlField.LengthField = null;
                }


                xmlDictionary.Fields.Entries.Add(xmlField);
            }
        }