Пример #1
0
        /// <summary>
        /// The CloneElement method creates a copy of the specified
        /// dictionary element and returns it to the caller.
        /// </summary>
        /// <param name="src">
        /// The data dictionary element to be cloned.
        /// </param>
        /// <returns>
        /// The resulting clone of the supplied element.
        /// </returns>
        private IFixDxElement CloneElement(IFixDxElement src)
        {
            IFixDxElement result = null;

            if (src is FixDxField)
            {
                result = CloneField(src as FixDxField);
            }
            else if (src is FixDxFieldReference)
            {
                result = CloneFieldReference(src as FixDxFieldReference);
            }
            else if (src is FixDxBlock)
            {
                result = CloneBlock(src as FixDxBlock);
            }
            else if (src is FixDxBlockReference)
            {
                result = CloneBlockReference(src as FixDxBlockReference);
            }
            else if (src is FixDxGroupReference)
            {
                result = CloneGroupReference(src as FixDxGroupReference);
            }


            return(result);
        }
Пример #2
0
 /// <summary>
 /// The PopulateTrailer method iterates over all of the elements
 /// that are defined in the trailer section of the QuickFix data
 /// dictionary and converts them into the trailer section of the
 /// supplied VersaFix data dictionary.
 /// </summary>
 /// <param name="src">
 /// The XML representation of the QuickFix dictionary that the
 /// trailer elements are to be read from.
 /// </param>
 /// <param name="dst">
 /// The VersaFix dictionary that the trailer elements are to be
 /// converted out to.
 /// </param>
 private void PopulateTrailer(XmlQfxDictionary src, FixDictionary dst)
 {
     foreach (object element in src.Trailer)
     {
         IFixDxElement dxElement = ConvertElement(element);
         if (dxElement != null)
         {
             dst.Trailer.Add(dxElement);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// The PopulateFields method is invoked to convert all of
        /// the FIX field definitions in an instance of a QuickFix
        /// dictionary into their corresponding representations as
        /// elements of a VersaFix dictionary.
        /// </summary>
        /// <param name="src">
        /// The XML representation of a QuickFix dictionary that the
        /// fields are to be copied from.
        /// </param>
        /// <param name="dst">
        /// The VersaFix data dictionary that the field definitions
        /// are to be copied into.
        /// </param>
        private void PopulateFields(XmlQfxDictionary src, FixDictionary dst)
        {
            foreach (object field in src.Fields)
            {
                XmlQfxField xmlField = field as XmlQfxField;
                if (xmlField != null)
                {
                    if (!string.IsNullOrEmpty(xmlField.Name))
                    {
                        if (!string.IsNullOrEmpty(xmlField.Number))
                        {
                            int        nTag    = int.Parse(xmlField.Number);
                            FixDxField dxField = new FixDxField(nTag, xmlField.Name);

                            // REC: Determine if there's an enumeration that corresponds
                            // to the name of this field:
                            if (dst.Enums.GetElement(xmlField.Name) != null)
                            {
                                // REC: If an enumeration exists for this field
                                // then assign it to the VersaFix field:
                                dxField.Enumeration = xmlField.Name;
                            }

                            // REC: Assign the field's data type directly
                            // from the data type in the QuickFix field.
                            dxField.Type = xmlField.Type;

                            dst.Fields.Add(dxField);

                            // REC: The QuickFix dictionaries do not provide
                            // a separate section for data types, so we need
                            // to just copy the data type directly from each
                            // of the QuickFix fields into the data types of
                            // the VersaFix dictionary:
                            if (!string.IsNullOrEmpty(xmlField.Type))
                            {
                                IFixDxElement exists = dst.DataTypes.GetElement(xmlField.Type);
                                if (exists == null)
                                {
                                    dst.DataTypes.Add(new FixDxDataType(xmlField.Type));
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #4
0
        private FixValidationResult CreateResult(IFixDxElement element)
        {
            FixValidationResult result = null;

            if (element is FixDxResolvedField)
            {
                FixDxResolvedField dxField = element as FixDxResolvedField;

                FixValidationResult fvr = new FixValidationResult();
                fvr.FieldTag      = dxField.Tag.ToString();
                fvr.FieldName     = dxField.Name;
                fvr.FieldValue    = null;
                fvr.FieldRequired = dxField.Required;
                fvr.ResultCode    = FixValidationCode.Field_Missing;
                fvr.ResultText    = "Field not present.";

                result = fvr;
            }
            else if (element is FixDxResolvedGroup)
            {
                FixDxResolvedGroup dxGroup = element as FixDxResolvedGroup;

                FixValidationResult fvr = new FixValidationResult();
                fvr.FieldTag      = dxGroup.Tag.ToString();
                fvr.FieldName     = dxGroup.Name;
                fvr.FieldValue    = null;
                fvr.FieldRequired = dxGroup.Required;
                fvr.ResultCode    = FixValidationCode.Field_Missing;
                fvr.ResultText    = "Group not present.";

                // REC: Expand all of the block references in the
                // group entry so that they can be added:
                foreach (IFixDxElement dxElement in dxGroup.Elements)
                {
                    fvr.Nodes.Add(CreateResult(dxElement));
                }

                result = fvr;
            }

            return(result);
        }
Пример #5
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);
                }
            }
        }
Пример #6
0
        /// <summary>
        /// The PopulateBlocks method is invoked to convert all of the
        /// component block definitions in a QuickFix dictionary into
        /// corresponding component block definitions in an instance of
        /// a VersaFix dictionary.
        /// </summary>
        /// <param name="src">
        /// The QuickFix dictionary to copy the blocks from.
        /// </param>
        /// <param name="dst">
        /// The VersaFix dictionary to copy the blocks into.
        /// </param>
        private void PopulateBlocks(XmlQfxDictionary src, FixDictionary dst)
        {
            foreach (object block in src.Blocks)
            {
                XmlQfxBlock xmlBlock = block as XmlQfxBlock;
                if (xmlBlock != null)
                {
                    if (!string.IsNullOrEmpty(xmlBlock.Name))
                    {
                        FixDxBlock dxBlock = new FixDxBlock(xmlBlock.Name);
                        foreach (object element in xmlBlock.Elements)
                        {
                            IFixDxElement dxElement = ConvertElement(element);
                            if (dxElement != null)
                            {
                                dxBlock.Elements.Add(dxElement);
                            }
                        }

                        dst.Blocks.Add(dxBlock);
                    }
                }
            }
        }
Пример #7
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);
                }
            }
        }
Пример #8
0
        /// <summary>
        /// The CloneElement method creates a copy of the specified
        /// dictionary element and returns it to the caller.
        /// </summary>
        /// <param name="src">
        /// The data dictionary element to be cloned.
        /// </param>
        /// <returns>
        /// The resulting clone of the supplied element.
        /// </returns>
        private IFixDxElement CloneElement(IFixDxElement src)
        {
            IFixDxElement result = null;
            if (src is FixDxField)
            {
                result = CloneField(src as FixDxField);
            }
            else if (src is FixDxFieldReference)
            {
                result = CloneFieldReference(src as FixDxFieldReference);
            }
            else if (src is FixDxBlock)
            {
                result = CloneBlock(src as FixDxBlock);
            }
            else if (src is FixDxBlockReference)
            {
                result = CloneBlockReference(src as FixDxBlockReference);
            }
            else if (src is FixDxGroupReference)
            {
                result = CloneGroupReference(src as FixDxGroupReference);
            }

            return result;
        }
Пример #9
0
        /// <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);
        }
Пример #10
0
        private FixValidationResult CreateResult(IFixDxElement element)
        {
            FixValidationResult result = null;

            if (element is FixDxResolvedField)
            {
                FixDxResolvedField dxField = element as FixDxResolvedField;

                FixValidationResult fvr = new FixValidationResult();
                fvr.FieldTag = dxField.Tag.ToString();
                fvr.FieldName = dxField.Name;
                fvr.FieldValue = null;
                fvr.FieldRequired = dxField.Required;
                fvr.ResultCode = FixValidationCode.Field_Missing;
                fvr.ResultText = "Field not present.";

                result = fvr;
            }
            else if (element is FixDxResolvedGroup)
            {
                FixDxResolvedGroup dxGroup = element as FixDxResolvedGroup;

                FixValidationResult fvr = new FixValidationResult();
                fvr.FieldTag = dxGroup.Tag.ToString();
                fvr.FieldName = dxGroup.Name;
                fvr.FieldValue = null;
                fvr.FieldRequired = dxGroup.Required;
                fvr.ResultCode = FixValidationCode.Field_Missing;
                fvr.ResultText = "Group not present.";

                // REC: Expand all of the block references in the
                // group entry so that they can be added:
                foreach (IFixDxElement dxElement in dxGroup.Elements)
                {
                    fvr.Nodes.Add(CreateResult(dxElement));
                }

                result = fvr;
            }

            return result;
        }