Exemplo n.º 1
0
        /// <summary>
        /// Clones this instance.
        /// </summary>
        /// <returns>
        /// A new object that is a copy of this instance.
        /// </returns>
        public XlsxSheetsSettingsCollection Clone()
        {
            var cloned = new XlsxSheetsSettingsCollection(Parent)
            {
                Properties = Properties.Clone()
            };

            foreach (XlsxSheetSettings sheet in this)
            {
                cloned.Add(sheet.Clone());
            }

            return(cloned);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Combines this instance with reference parameter.
        /// </summary>
        /// <param name="reference">The reference.</param>
        public virtual void Combine(XlsxSheetsSettingsCollection reference)
        {
            if (reference == null)
            {
                return;
            }

            var hasElements = this.Any();

            if (!hasElements)
            {
                foreach (var referenceSheet in reference)
                {
                    var sheet = referenceSheet.Clone();
                    sheet.SetOwner(this);
                    Add(sheet);
                }
            }
            else
            {
                foreach (var sheet in this)
                {
                    var refSheet = reference.GetBy(sheet.SheetName);
                    if (refSheet != null)
                    {
                        sheet.Combine(refSheet);
                    }
                }

                foreach (var referenceSheet in reference)
                {
                    var sheet = GetBy(referenceSheet.SheetName);
                    if (sheet != null)
                    {
                        continue;
                    }

                    var newSheet = referenceSheet.Clone();
                    newSheet.SetOwner(this);
                    Add(newSheet);
                }
            }
        }