/// <summary> /// Initializes new instance of <see cref="DicomAttribute"/>. /// </summary> /// <param name="dicomTag">Specifies to which dicom tag should be property mapped to</param> /// <exception cref="ArgumentException"><paramref name="dicomTag"/> cannot be set to <see cref="DicomTags.Undefined"/></exception> public DicomAttribute(DicomTags dicomTag) { if (dicomTag == DicomTags.Undefined) { throw new ArgumentException($"Dicom tag cannot be set to {DicomTags.Undefined}", nameof(dicomTag)); } DicomTag = dicomTag; }
/// <summary> /// Gets <see cref="DicomTag"/> instance from the given <paramref name="dicomTag"/>. /// </summary> /// <param name="dicomTag">Dicom tag to be converted to the <see cref="DicomTag"/></param> /// <exception cref="ArgumentException"><paramref name="dicomTag"/> cannot be set to <see cref="DicomTags.Undefined"/></exception> /// <returns>Instance of <see cref="DicomTag"/> corresponding to the given <paramref name="dicomTag"/></returns> public object GetDicomTag(DicomTags dicomTag) { if (dicomTag == DicomTags.Undefined) { throw new ArgumentException($"Dicom tag cannot be set to {DicomTags.Undefined}", nameof(dicomTag)); } FieldInfo fieldInfo = typeof(DicomTag).GetField(dicomTag.ToString(), BindingFlags.Static | BindingFlags.Public); return (DicomTag) fieldInfo?.GetValue(null); }