Exemple #1
0
        /// <summary>
        /// The TranslateElements method iterates over a list of objects
        /// from an entity in the XML representation of a dictionary and
        /// translates them into a collection of VFX dictionary types.
        /// </summary>
        /// <param name="elements">
        /// The list of objects from an entity in the XML representation
        /// of a VersaFix dictionary.
        /// </param>
        /// <returns>
        /// An instance of FixDxCollection that has been populated with
        /// the VersaFix dictionary types that correspond to the objects
        /// in the list of XML elements.
        /// </returns>
        private static FixDxCollection TranslateElements(List <object> elements)
        {
            FixDxCollection result = new FixDxCollection();

            foreach (object element in elements)
            {
                if (element is XmlFixDxFieldReference)
                {
                    XmlFixDxFieldReference src = element as XmlFixDxFieldReference;
                    result.Add(new FixDxFieldReference(src.Name, src.Required));
                }
                else if (element is XmlFixDxGroupReference)
                {
                    XmlFixDxGroupReference src = element as XmlFixDxGroupReference;
                    FixDxGroupReference    dst = new FixDxGroupReference(src.Name, src.Required);

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

                    result.Add(dst);
                }
                else if (element is XmlFixDxBlockReference)
                {
                    XmlFixDxBlockReference src = element as XmlFixDxBlockReference;
                    result.Add(new FixDxBlockReference(src.Name, src.Required));
                }
            }

            return(result);
        }
Exemple #2
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);
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// The TranslateElements method converts a collection of
        /// dictionary elements into their corresponding representation
        /// as instances of XML serializable classes. The method only
        /// translates field, group, and block references, since those
        /// are the only elements that should be found in collections
        /// of dictionary elements under normal usage.
        /// </summary>
        /// <param name="dxElements">
        /// The collection of field, group, and block references that
        /// is to be converted to XML serializable classes.
        /// </param>
        /// <returns>
        /// The resulting collection of XML serializable classes.
        /// </returns>
        private static XmlFixDxElements TranslateElements(FixDxCollection dxElements)
        {
            XmlFixDxElements result = new XmlFixDxElements();

            foreach (IFixDxElement dxElement in dxElements)
            {
                if (dxElement is FixDxFieldReference)
                {
                    FixDxFieldReference    dxReference  = dxElement as FixDxFieldReference;
                    XmlFixDxFieldReference xmlReference = new XmlFixDxFieldReference();
                    xmlReference.Name     = dxReference.Name;
                    xmlReference.Required = dxReference.Required;
                    result.Elements.Add(xmlReference);
                }
                else if (dxElement is FixDxGroupReference)
                {
                    FixDxGroupReference    dxReference  = dxElement as FixDxGroupReference;
                    XmlFixDxGroupReference xmlReference = new XmlFixDxGroupReference();
                    xmlReference.Name     = dxReference.Name;
                    xmlReference.Required = dxReference.Required;
                    XmlFixDxElements xmlElements = TranslateElements(dxReference.Elements);
                    foreach (object xmlElement in xmlElements.Elements)
                    {
                        xmlReference.Elements.Add(xmlElement);
                    }
                    result.Elements.Add(xmlReference);
                }
                else if (dxElement is FixDxBlockReference)
                {
                    FixDxBlockReference    dxReference  = dxElement as FixDxBlockReference;
                    XmlFixDxBlockReference xmlReference = new XmlFixDxBlockReference();
                    xmlReference.Name     = dxReference.Name;
                    xmlReference.Required = dxReference.Required;
                    result.Elements.Add(xmlReference);
                }
            }

            return(result);
        }
Exemple #4
0
        /// <summary>
        /// The TranslateElements method converts a collection of
        /// dictionary elements into their corresponding representation
        /// as instances of XML serializable classes. The method only
        /// translates field, group, and block references, since those
        /// are the only elements that should be found in collections
        /// of dictionary elements under normal usage.
        /// </summary>
        /// <param name="dxElements">
        /// The collection of field, group, and block references that
        /// is to be converted to XML serializable classes.
        /// </param>
        /// <returns>
        /// The resulting collection of XML serializable classes.
        /// </returns>
        private static XmlFixDxElements TranslateElements(FixDxCollection dxElements)
        {
            XmlFixDxElements result = new XmlFixDxElements();
            foreach (IFixDxElement dxElement in dxElements)
            {
                if (dxElement is FixDxFieldReference)
                {
                    FixDxFieldReference dxReference = dxElement as FixDxFieldReference;
                    XmlFixDxFieldReference xmlReference = new XmlFixDxFieldReference();
                    xmlReference.Name = dxReference.Name;
                    xmlReference.Required = dxReference.Required;
                    result.Elements.Add(xmlReference);
                }
                else if (dxElement is FixDxGroupReference)
                {
                    FixDxGroupReference dxReference = dxElement as FixDxGroupReference;
                    XmlFixDxGroupReference xmlReference = new XmlFixDxGroupReference();
                    xmlReference.Name = dxReference.Name;
                    xmlReference.Required = dxReference.Required;
                    XmlFixDxElements xmlElements = TranslateElements(dxReference.Elements);
                    foreach (object xmlElement in xmlElements.Elements)
                    {
                        xmlReference.Elements.Add(xmlElement);
                    }
                    result.Elements.Add(xmlReference);

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

            return result;
        }
Exemple #5
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);
                }
            }
        }