/// <summary> /// Copies a Virtual Resource and all of its 'configuration data' - but does NOT /// copy the Metadata items. /// </summary> /// <returns>The Copy of the Virtual Resource</returns> public VirtualResource ShallowCopy() { // Create a new resource of the same type as this one using reflection VirtualResource newResource = (VirtualResource)Activator.CreateInstance(this.GetType()); newResource.CopyResourceProperties(this); return(newResource); }
/// <summary> /// Creates a copy of this <see cref="VirtualResource"/>. /// </summary> /// <returns></returns> public VirtualResource Copy() { // Create a new resource of the same type as this one using reflection VirtualResource newResource = (VirtualResource)Activator.CreateInstance(this.GetType()); newResource.CopyResourceProperties(this); // Copy over all metadata items foreach (VirtualResourceMetadata metadata in this.VirtualResourceMetadataSet) { VirtualResourceMetadata copiedMetadata = metadata.Copy(true); copiedMetadata.VirtualResourceId = newResource.VirtualResourceId; newResource.VirtualResourceMetadataSet.Add(copiedMetadata); } return(newResource); }