public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as AgentComponent; if (dest != null) { base.CopyTo(dest); if (Role != null) { dest.Role = (Hl7.Fhir.Model.Coding)Role.DeepCopy(); } if (Actor != null) { dest.Actor = (Hl7.Fhir.Model.ResourceReference)Actor.DeepCopy(); } if (UserId != null) { dest.UserId = (Hl7.Fhir.Model.Identifier)UserId.DeepCopy(); } if (RelatedAgent != null) { dest.RelatedAgent = new List <Hl7.Fhir.Model.Provenance.RelatedAgentComponent>(RelatedAgent.DeepCopy()); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }