コード例 #1
0
        private void ExportElement(IFixDxElement dxElement, List <object> dst)
        {
            if (dxElement is FixDxFieldReference)
            {
                FixDxFieldReference dxField = dxElement as FixDxFieldReference;
                if (dxField != null)
                {
                    XmlQfxFieldReference xmlField = new XmlQfxFieldReference();
                    xmlField.Name     = dxField.Name;
                    xmlField.Required = (dxField.Required == true) ? "Y" : "N";
                    dst.Add(xmlField);
                }
            }
            else if (dxElement is FixDxBlockReference)
            {
                FixDxBlockReference dxBlock = dxElement as FixDxBlockReference;
                if (dxBlock != null)
                {
                    XmlQfxBlockReference xmlBlock = new XmlQfxBlockReference();
                    xmlBlock.Name     = dxBlock.Name;
                    xmlBlock.Required = (dxBlock.Required == true) ? "Y" : "N";
                    dst.Add(xmlBlock);
                }
            }
            else if (dxElement is FixDxGroupReference)
            {
                FixDxGroupReference dxGroup = dxElement as FixDxGroupReference;
                if (dxGroup != null)
                {
                    XmlQfxGroupReference xmlGroup = new XmlQfxGroupReference();
                    xmlGroup.Name     = dxGroup.Name;
                    xmlGroup.Required = (dxGroup.Required == true) ? "Y" : "N";

                    foreach (IFixDxElement dxGroupElement in dxGroup.Elements)
                    {
                        ExportElement(dxGroupElement, xmlGroup.Elements);
                    }

                    dst.Add(xmlGroup);
                }
            }
        }
コード例 #2
0
ファイル: QfxFixDxImporter.cs プロジェクト: recurry/VersaFix
        /// <summary>
        /// The ConvertElement method converts an instance of an XML element
        /// from a QuickFix dictionary into its corresponding representation
        /// as an element in a VersaFix dictionary.
        /// </summary>
        /// <param name="xmlElement">
        /// The XML representation of a QuickFix dictionary element that is
        /// to be converted into an instance of a VersaFix element.
        /// </param>
        /// <returns>
        /// The VersaFix dictionary element that results from the conversion
        /// attempt, or null if the conversion could not be carried out.
        /// </returns>
        private IFixDxElement ConvertElement(object xmlElement)
        {
            IFixDxElement result = null;

            if (xmlElement is XmlQfxFieldReference)
            {
                XmlQfxFieldReference xmlField = xmlElement as XmlQfxFieldReference;
                if (xmlField != null)
                {
                    if (!string.IsNullOrEmpty(xmlField.Name))
                    {
                        bool required = false;
                        if (xmlField.Required.CompareTo("Y") == 0)
                        {
                            required = true;
                        }

                        FixDxFieldReference dxField = new FixDxFieldReference(xmlField.Name, required);
                        result = dxField;
                    }
                }
            }
            else if (xmlElement is XmlQfxBlockReference)
            {
                XmlQfxBlockReference xmlBlock = xmlElement as XmlQfxBlockReference;
                if (xmlBlock != null)
                {
                    if (!string.IsNullOrEmpty(xmlBlock.Name))
                    {
                        bool required = false;
                        if (xmlBlock.Required.CompareTo("Y") == 0)
                        {
                            required = true;
                        }

                        FixDxBlockReference dxBlock = new FixDxBlockReference(xmlBlock.Name, required);
                        result = dxBlock;
                    }
                }
            }
            else if (xmlElement is XmlQfxGroupReference)
            {
                XmlQfxGroupReference xmlGroup = xmlElement as XmlQfxGroupReference;
                if (xmlGroup != null)
                {
                    if (!string.IsNullOrEmpty(xmlGroup.Name))
                    {
                        bool required = false;
                        if (xmlGroup.Required.CompareTo("Y") == 0)
                        {
                            required = true;
                        }

                        FixDxGroupReference dxGroup = new FixDxGroupReference(xmlGroup.Name, required);
                        foreach (object element in xmlGroup.Elements)
                        {
                            IFixDxElement dxElement = ConvertElement(element);
                            if (dxElement != null)
                            {
                                dxGroup.Elements.Add(dxElement);
                            }
                        }

                        result = dxGroup;
                    }
                }
            }

            return(result);
        }