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 new object that is a copy of this instance.
        /// </returns>
        public object Clone()
        {
            FormattingConfiguration clone = new FormattingConfiguration();

            if (_closingComments != null)
            {
                clone._closingComments = _closingComments.Clone() as ClosingCommentConfiguration;
            }

            if (_regions != null)
            {
                clone._regions = _regions.Clone() as RegionFormatConfiguration;
            }

            if (_tabs != null)
            {
                clone._tabs = _tabs.Clone() as TabConfiguration;
            }

            if (_lineSpacing != null)
            {
                clone._lineSpacing = _lineSpacing.Clone() as LineSpacingConfiguration;
            }

            if (_usings != null)
            {
                clone._usings = _usings.Clone() as UsingConfiguration;
            }

            return(clone);
        }
        public void CloneTest()
        {
            UsingConfiguration usingConfiguration = new UsingConfiguration();
            usingConfiguration.MoveTo = CodeLevel.Namespace;

            UsingConfiguration clone = usingConfiguration.Clone() as UsingConfiguration;
            Assert.IsNotNull(clone, "Clone did not return a valid instance.");

            Assert.AreEqual(
                usingConfiguration.MoveTo,
                clone.MoveTo);
        }