Clone() public method

Creates a clone of this instance.
public Clone ( ) : object
return object
Esempio n. 1
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>A clone of the instance.</returns>
        public object Clone()
        {
            SortBy clone = new SortBy();

            clone._by        = _by;
            clone._direction = _direction;

            if (_innerSortBy != null)
            {
                clone._innerSortBy = _innerSortBy.Clone() as SortBy;
            }

            return(clone);
        }
Esempio n. 2
0
        public void CloneTest()
        {
            SortBy sortBy = new SortBy();
            sortBy.By = ElementAttributeType.Name;
            sortBy.Direction = SortDirection.Descending;

            SortBy innerSortBy = new SortBy();
            innerSortBy.By = ElementAttributeType.Type;
            innerSortBy.Direction = SortDirection.Ascending;
            sortBy.InnerSortBy = innerSortBy;

            SortBy clone = sortBy.Clone() as SortBy;
            Assert.AreEqual(sortBy.By, clone.By, "By was not copied correctly");
            Assert.AreEqual(sortBy.Direction, clone.Direction, "Direction was not copied correctly");
            Assert.IsNotNull(clone.InnerSortBy, "InnerSortBy was not copied correctly");
            Assert.AreEqual(sortBy.InnerSortBy.By, clone.InnerSortBy.By, "InnerSortBy was not copied correctly");
            Assert.AreEqual(sortBy.InnerSortBy.Direction, clone.InnerSortBy.Direction, "InnerSortBy was not copied correctly");
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a clone of this instance.
        /// </summary>
        /// <returns>Clone of the instance.</returns>
        protected override ConfigurationElement DoClone()
        {
            ElementConfiguration clone = new ElementConfiguration();

            clone._elementType = _elementType;
            clone._id          = _id;

            if (_filterBy != null)
            {
                clone._filterBy = _filterBy.Clone() as FilterBy;
            }

            if (_groupBy != null)
            {
                clone._groupBy = _groupBy.Clone() as GroupBy;
            }

            if (_sortBy != null)
            {
                clone._sortBy = _sortBy.Clone() as SortBy;
            }

            return(clone);
        }
Esempio n. 4
0
        /// <summary>
        /// Creates a new sorted inserter using the specified sorting configuration.
        /// </summary>
        /// <param name="elementType">Type of the element.</param>
        /// <param name="sortBy">The sort by.</param>
        public SortedInserter(ElementType elementType, SortBy sortBy)
        {
            if (sortBy == null)
            {
                throw new ArgumentNullException("sortBy");
            }

            _elementType = elementType;
            _sortBy = sortBy.Clone() as SortBy;
        }