Пример #1
0
        /**
         * Our handling of Equals is inconsistent with CompareTo.  The trouble is because we don't truely understand
         * rich text fields yet it's difficult to make a sound comparison.
         *
         * @param o     The object to Compare.
         * @return      true if the object is actually Equal.
         */
        public override bool Equals(Object o)
        {
            if (!(o is UnicodeString))
            {
                return(false);
            }
            UnicodeString other = (UnicodeString)o;

            //OK lets do this in stages to return a quickly, first check the actual string
            if (field_1_charCount != other.field_1_charCount ||
                field_2_optionflags != other.field_2_optionflags ||
                !field_3_string.Equals(other.field_3_string))
            {
                return(false);
            }

            //OK string appears to be equal but now lets compare formatting Runs
            if (field_4_format_runs == null)
            {
                // Strings are equal, and there are not formatting runs.
                return(other.field_4_format_runs == null);
            }
            else if (other.field_4_format_runs == null)
            {
                // Strings are equal, but one or the other has formatting runs
                return(false);
            }

            //Strings are Equal, so now compare formatting Runs.
            int size = field_4_format_runs.Count;

            if (size != other.field_4_format_runs.Count)
            {
                return(false);
            }

            for (int i = 0; i < size; i++)
            {
                FormatRun Run1 = field_4_format_runs[(i)];
                FormatRun run2 = other.field_4_format_runs[(i)];

                if (!Run1.Equals(run2))
                {
                    return(false);
                }
            }

            // Well the format Runs are equal as well!, better check the ExtRst data
            if (field_5_ext_rst == null)
            {
                return(other.field_5_ext_rst == null);
            }
            else if (other.field_5_ext_rst == null)
            {
                return(false);
            }

            return(field_5_ext_rst.Equals(other.field_5_ext_rst));
        }
Пример #2
0
        /**
         * Our handling of equals is inconsistent with CompareTo.  The trouble is because we don't truely understand
         * rich text fields yet it's difficult to make a sound comparison.
         *
         * @param o     The object to Compare.
         * @return      true if the object is actually equal.
         */
        public override bool Equals(Object o)
        {
            if (!(o is UnicodeString))
            {
                return(false);
            }
            UnicodeString other = (UnicodeString)o;

            //OK lets do this in stages to return a quickly, first check the actual string
            bool eq = ((field_1_charCount == other.field_1_charCount) &&
                       (field_2_optionflags == other.field_2_optionflags) &&
                       field_3_string.Equals(other.field_3_string));

            if (!eq)
            {
                return(false);
            }

            //OK string appears to be equal but now lets compare formatting Runs
            if ((field_4_format_Runs == null) && (other.field_4_format_Runs == null))
            {
                //Strings are equal, and there are not formatting Runs.
                return(true);
            }
            if (((field_4_format_Runs == null) && (other.field_4_format_Runs != null)) ||
                (field_4_format_Runs != null) && (other.field_4_format_Runs == null))
            {
                //Strings are equal, but one or the other has formatting Runs
                return(false);
            }

            //Strings are equal, so now compare formatting Runs.
            int size = field_4_format_Runs.Count;

            if (size != other.field_4_format_Runs.Count)
            {
                return(false);
            }

            for (int i = 0; i < size; i++)
            {
                FormatRun Run1 = field_4_format_Runs[i];
                FormatRun Run2 = other.field_4_format_Runs[i];

                if (!Run1.Equals(Run2))
                {
                    return(false);
                }
            }

            //Well the format Runs are equal as well!, better check the ExtRst data
            //Which by the way we dont know how to decode!
            if ((field_5_ext_rst == null) && (other.field_5_ext_rst == null))
            {
                return(true);
            }
            if (((field_5_ext_rst == null) && (other.field_5_ext_rst != null)) ||
                ((field_5_ext_rst != null) && (other.field_5_ext_rst == null)))
            {
                return(false);
            }
            size = field_5_ext_rst.Length;
            if (size != field_5_ext_rst.Length)
            {
                return(false);
            }

            //Check individual bytes!
            for (int i = 0; i < size; i++)
            {
                if (field_5_ext_rst[i] != other.field_5_ext_rst[i])
                {
                    return(false);
                }
            }
            //Phew!! After all of that we have finally worked out that the strings
            //are identical.
            return(true);
        }
Пример #3
0
        /**
         * Our handling of Equals is inconsistent with CompareTo.  The trouble is because we don't truely understand
         * rich text fields yet it's difficult to make a sound comparison.
         *
         * @param o     The object to Compare.
         * @return      true if the object is actually Equal.
         */
        public override bool Equals(Object o)
        {
            if (!(o is UnicodeString))
            {
                return(false);
            }
            UnicodeString other = (UnicodeString)o;

            //OK lets do this in stages to return a quickly, first check the actual string
            bool eq = ((field_1_charCount == other.field_1_charCount) &&
                       (field_2_optionflags == other.field_2_optionflags) &&
                       field_3_string.Equals(other.field_3_string));

            if (!eq)
            {
                return(false);
            }

            //OK string appears to be equal but now lets compare formatting Runs
            if ((field_4_format_Runs == null) && (other.field_4_format_Runs == null))
            {
                //Strings are Equal, and there are not formatting Runs.
                return(true);
            }
            if (((field_4_format_Runs == null) && (other.field_4_format_Runs != null)) ||
                (field_4_format_Runs != null) && (other.field_4_format_Runs == null))
            {
                //Strings are Equal, but one or the other has formatting Runs
                return(false);
            }

            //Strings are Equal, so now compare formatting Runs.
            int size = field_4_format_Runs.Count;

            if (size != other.field_4_format_Runs.Count)
            {
                return(false);
            }

            for (int i = 0; i < size; i++)
            {
                FormatRun Run1 = field_4_format_Runs[(i)];
                FormatRun run2 = other.field_4_format_Runs[(i)];

                if (!Run1.Equals(run2))
                {
                    return(false);
                }
            }

            // Well the format Runs are equal as well!, better check the ExtRst data
            if (field_5_ext_rst == null && other.field_5_ext_rst == null)
            {
                // Good
            }
            else if (field_5_ext_rst != null && other.field_5_ext_rst != null)
            {
                int extCmp = field_5_ext_rst.CompareTo(other.field_5_ext_rst);
                if (extCmp == 0)
                {
                    // Good
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }

            //Phew!! After all of that we have finally worked out that the strings
            //are identical.
            return(true);
        }