Esempio n. 1
0
        /// <summary>
        /// The ConvertElements method converts all of the elements
        /// in an instance of FixCollection into their corresponding
        /// representation as a text string. This is a helper method
        /// for the FixMessage class implementation of ToString().
        /// </summary>
        /// <param name="elements">
        /// The collection of elements that are to be converted into
        /// their corresponding representation as a string.
        /// </param>
        /// <returns>
        /// The string that results from the conversion.
        /// </returns>
        private string ConvertElements(FixCollection elements)
        {
            StringBuilder sb = new StringBuilder();

            foreach (IFixElement element in elements)
            {
                sb.Append(string.Format("{0}={1}\x01", element.Tag, element.Content));
                FixGroup group = element as FixGroup;
                if (group != null)
                {
                    foreach (FixCollection instance in group.Instances)
                    {
                        sb.Append(ConvertElements(instance));
                    }
                }
            }

            return(sb.ToString());
        }
Esempio n. 2
0
        // REC: The CalculateLength method calculates the combined
        // length of all of the elements in a collection. This is
        // a support method for the CalculateBodyLength method.
        private static int CalculateLength(FixCollection collection)
        {
            int result = 0;

            foreach (IFixElement element in collection)
            {
                result += element.Tag.ToString().Length;
                result += 1;
                result += element.Content.Length;
                result += 1;

                FixGroup group = element as FixGroup;
                if (group != null)
                {
                    foreach (FixCollection instance in group.Instances)
                    {
                        result += CalculateLength(instance);
                    }
                }
            }

            return(result);
        }
Esempio n. 3
0
        private static int CalculateSum(FixCollection elements)
        {
            int result = 0;

            foreach (IFixElement element in elements)
            {
                result += CalculateSum(element.Tag.ToString());
                result += 0x3D;
                result += CalculateSum(element.Content);
                result += 0x01;

                FixGroup group = element as FixGroup;
                if (group != null)
                {
                    foreach (FixCollection instance in group.Instances)
                    {
                        result += CalculateSum(instance);
                    }
                }
            }

            return(result);
        }