Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            string str = "Deep++\n";

            PropertyDeepEnumerator enumerator = GetDeepEnumerator();

            while (enumerator.MoveNext() != enumerator.RightBound)
            {
                for (int i = 0; i < enumerator.Depth; i++)
                {
                    str += "-";
                }
                str += enumerator.Property.ToString() + "\n";
            }

            str += "\n\nDeep--\n";

            enumerator.MoveToRightBound();
            while (enumerator.MovePrev() != enumerator.LeftBound)
            {
                for (int i = 0; i < enumerator.Depth; i++)
                {
                    str += "-";
                }
                str += enumerator.Property.ToString() + "\n";
            }

            return(str);
        }
Пример #2
0
        /// <summary>
        /// Removes a property from the tree.
        /// </summary>
        /// <param name="propEnum">An enumerator pointing to the property to remove from the tree.</param>
        /// <returns>A deep enumerator on the property that would be naturally selected if the deleted
        /// item was selected.</returns>
        public PropertyEnumerator Delete(PropertyEnumerator propEnum)
        {
            // Store the previous property (deep)
            PropertyDeepEnumerator dEnumerator = new PropertyDeepEnumerator(propEnum.Node);

            dEnumerator.MovePrev();

            // Remove the property
            propEnum.Node.Owner.Remove(propEnum.Node);

            // Determine the next property of the property that was deleted
            if (dEnumerator.MoveNext() == dEnumerator.RightBound)
            {
                dEnumerator.MovePrev();
            }
            if (dEnumerator == dEnumerator.LeftBound)
            {
                dEnumerator = dEnumerator.RightBound.GetDeepEnumerator();
            }

            // Since the enumerator passed in argument now points to an invalid property,
            // we make it point to the next property (the previous one if no next exists)
            propEnum.Node = dEnumerator.Node;

            return(dEnumerator);
        }
Пример #3
0
        public static bool operator <(PropertyEnumerator propEnum1, PropertyEnumerator propEnum2)
        {
            PropertyDeepEnumerator currentEnumerator = new PropertyDeepEnumerator(propEnum1.Node);

            while (currentEnumerator.MoveNext() != currentEnumerator.RightBound)
            {
                if (currentEnumerator == propEnum2)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #4
0
        /// <summary>
        /// Searches a property given its ID inside the whole property tree but only from a given enumerator and beyond.
        /// The enumerator can be sibling or deep and will restrict the search accordingly.
        /// </summary>
        /// <param name="afterEnumerator">The enumerator from which the property will be searched.</param>
        /// <param name="propertyId">The ID of the property being searched.</param>
        /// <returns>A deep enumerator pointing to the found property. If not found it will point to RightBound.</returns>
        public PropertyEnumerator FindAfter(PropertyEnumerator afterEnumerator, int propertyId)
        {
            PropertyEnumerator propEnum = new PropertyDeepEnumerator(afterEnumerator.Node);

            while (propEnum.MoveNext() != propEnum.RightBound)
            {
                if (propEnum.Property.Id == propertyId)
                {
                    break;
                }
            }

            // If the element is not found, the enumerator will point to RightBound
            return(propEnum);
        }
Пример #5
0
        /// <summary>
        /// Searches a property given its ID inside the whole property tree but only from a given enumerator and beyond.
        /// The enumerator can be sibling or deep and will restrict the search accordingly.
        /// </summary>
        /// <param name="afterEnumerator">The enumerator from which the property will be searched.</param>
        /// <param name="propertyId">The ID of the property being searched.</param>
        /// <returns>A deep enumerator pointing to the found property. If not found it will point to RightBound.</returns>
        public PropertyEnumerator FindAfter(PropertyEnumerator afterEnumerator, int propertyId)
        {
            PropertyEnumerator propEnum = new PropertyDeepEnumerator(afterEnumerator.Node);
            while (propEnum.MoveNext() != propEnum.RightBound)
            {
                if (propEnum.Property.Id == propertyId)
                    break;
            }

            // If the element is not found, the enumerator will point to RightBound
            return propEnum;
        }
Пример #6
0
        public static bool operator <(PropertyEnumerator propEnum1, PropertyEnumerator propEnum2)
        {
            PropertyDeepEnumerator currentEnumerator = new PropertyDeepEnumerator(propEnum1.Node);
            while (currentEnumerator.MoveNext() != currentEnumerator.RightBound)
            {
                if (currentEnumerator == propEnum2)
                    return true;
            }

            return false;
        }
Пример #7
0
        /// <summary>
        /// Removes a property from the tree.
        /// </summary>
        /// <param name="propEnum">An enumerator pointing to the property to remove from the tree.</param>
        /// <returns>A deep enumerator on the property that would be naturally selected if the deleted
        /// item was selected.</returns>
        public PropertyEnumerator Delete(PropertyEnumerator propEnum)
        {
            // Store the previous property (deep)
            PropertyDeepEnumerator dEnumerator = new PropertyDeepEnumerator(propEnum.Node);
            dEnumerator.MovePrev();

            // Remove the property
            propEnum.Node.Owner.Remove(propEnum.Node);

            // Determine the next property of the property that was deleted
            if (dEnumerator.MoveNext() == dEnumerator.RightBound)
                dEnumerator.MovePrev();
            if (dEnumerator == dEnumerator.LeftBound)
                dEnumerator = dEnumerator.RightBound.GetDeepEnumerator();

            // Since the enumerator passed in argument now points to an invalid property,
            // we make it point to the next property (the previous one if no next exists)
            propEnum.Node = dEnumerator.Node;

            return dEnumerator;
        }