/// <summary> /// Creates a deep-copy clone of this instance. /// </summary> /// <returns>The cloned instance.</returns> protected virtual object CloneOverride() { var newLayer = (iLayer)MemberwiseClone(); newLayer.ID = Guid.NewGuid().ToString(); newLayer.ActionButtons = new List <Button>(ActionButtons.Select(a => a.Clone())); newLayer.Items = new List <iLayerItem>(Items.Select(i => { var clone = i.Clone(); if (i == FocusedItem) { newLayer.FocusedItem = clone; } else { var list = i as IList; int index = -1; if (list != null && (index = list.IndexOf(FocusedItem)) >= 0) { newLayer.FocusedItem = ((IList)clone)[index]; } } return(clone); })); if (BackButton != null) { newLayer.BackButton = BackButton.Clone(); } if (CompositeLayerLink != null) { newLayer.CompositeLayerLink = CompositeLayerLink.Clone(); } if (CompositeActionButton != null) { newLayer.CompositeActionButton = CompositeActionButton.Clone(); } if (DetailLink != null) { newLayer.DetailLink = DetailLink.Clone(); } if (FieldValuesRequested != null) { newLayer.FieldValuesRequested = FieldValuesRequested; } newLayer.LayerStyle = LayerStyle.Clone(); return(newLayer); }