private void WriteCondition(TrackingCondition condition, XmlTextWriter writer)
        {
            if (null == condition)
                return;

            writer.WriteStartElement(condition.GetType().Name);

            writer.WriteElementString("Operator", condition.Operator.ToString());

            if ((null == condition.Member) || (0 == condition.Member.Trim().Length))
                throw new ArgumentException(ExecutionStringManager.MissingMemberName);

            writer.WriteElementString("Member", condition.Member);

            if (null != condition.Value)
            {
                if (string.Empty == condition.Value)
                {
                    writer.WriteStartElement("Value");
                    writer.WriteRaw(string.Empty);
                    writer.WriteEndElement();
                }
                else
                    writer.WriteElementString("Value", condition.Value);
            }

            writer.WriteEndElement();
        }
        private void CreateCondition(XmlReader reader, TrackingCondition condition)
        {
            if (null == reader)
                throw new ArgumentNullException("reader");

            if (null == condition)
                throw new ArgumentNullException("condition");

            if (0 != string.Compare(condition.GetType().Name, reader.Name, StringComparison.Ordinal))
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + condition.GetType().Name);

            if (reader.IsEmptyElement)
                return;

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        if (0 == string.Compare(reader.Name, "Member", StringComparison.Ordinal))
                        {
                            condition.Member = reader.ReadString();
                        }
                        else if (0 == string.Compare(reader.Name, "Operator", StringComparison.Ordinal))
                        {
                            string op = reader.ReadString();
                            if ((null != op) && (op.Trim().Length > 0))
                            {
                                string[] names = Enum.GetNames(typeof(ComparisonOperator));
                                foreach (string s in names)
                                {
                                    if (0 == string.Compare(s, op, StringComparison.Ordinal))
                                        condition.Operator = (ComparisonOperator)Enum.Parse(typeof(ComparisonOperator), op);
                                }
                            }
                        }
                        else if (0 == string.Compare(reader.Name, "Value", StringComparison.Ordinal))
                        {
                            if (!reader.IsEmptyElement)
                                condition.Value = reader.ReadString();
                        }
                        //
                        // Xsd validation will catch unknown elements

                        break;
                    case XmlNodeType.EndElement:
                        if (0 == string.Compare(reader.Name, condition.GetType().Name, StringComparison.Ordinal))
                            return;
                        break;
                }
            }
            //
            // Only valid exit is on an EndElement that matches the element that is passed in.
            throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + condition.GetType().Name);
        }
        private void CreateCondition(XmlReader reader, TrackingCondition condition)
        {
            if (reader == null)
            {
                throw new ArgumentNullException("reader");
            }
            if (condition == null)
            {
                throw new ArgumentNullException("condition");
            }
            if (string.Compare(condition.GetType().Name, reader.Name, StringComparison.Ordinal) != 0)
            {
                throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationInvalidPosition + condition.GetType().Name);
            }
            if (!reader.IsEmptyElement)
            {
                while (true)
                {
                    if (!reader.Read())
                    {
                        throw new TrackingProfileDeserializationException(ExecutionStringManager.TrackingDeserializationCloseElementNotFound + condition.GetType().Name);
                    }
                    switch (reader.NodeType)
                    {
                        case XmlNodeType.Element:
                            if (string.Compare(reader.Name, "Member", StringComparison.Ordinal) == 0)
                            {
                                condition.Member = reader.ReadString();
                                break;
                            }
                            if (string.Compare(reader.Name, "Operator", StringComparison.Ordinal) == 0)
                            {
                                string strB = reader.ReadString();
                                if ((strB != null) && (strB.Trim().Length > 0))
                                {
                                    foreach (string str2 in Enum.GetNames(typeof(ComparisonOperator)))
                                    {
                                        if (string.Compare(str2, strB, StringComparison.Ordinal) == 0)
                                        {
                                            condition.Operator = (ComparisonOperator) Enum.Parse(typeof(ComparisonOperator), strB);
                                        }
                                    }
                                }
                            }
                            else if ((string.Compare(reader.Name, "Value", StringComparison.Ordinal) == 0) && !reader.IsEmptyElement)
                            {
                                condition.Value = reader.ReadString();
                            }
                            break;

                        case XmlNodeType.EndElement:
                            if (string.Compare(reader.Name, condition.GetType().Name, StringComparison.Ordinal) == 0)
                            {
                                return;
                            }
                            break;
                    }
                }
            }
        }