/// <summary> /// Retrieve an UID value. /// /// <see cref="DicomUid"/> /// </summary> /// <param name="i"></param> /// <param name="defaultVal"></param> /// <returns></returns> public virtual DicomUid GetUid(int i, DicomUid defaultVal) { try { DicomUid value; bool ok = TryGetUid(i, out value); if (!ok) return defaultVal; return value; } catch (Exception) { return defaultVal; } }
/// <summary> /// Retrieves a <see cref="DicomUid"/> instance for a value. /// </summary> /// <remarks>This function only works for <see cref="DicomAttributeUI"/> attributes.</remarks> /// <param name="i"></param> /// <param name="value"></param> /// <returns>True on success, false on failure.</returns> public virtual bool TryGetUid(int i, out DicomUid value) { value = null; return false; }
/// <summary> /// Append an uid to the tag. /// </summary> /// <param name="intValue"></param> public virtual void AppendUid(DicomUid uid) { throw new DicomException(SR.InvalidType); }
public virtual void SetUid(int index, DicomUid value) { throw new DicomException(SR.InvalidType); }
/// <summary> /// Append a UI value based on a DicomUid object. /// /// </summary> /// <param name="value"></param> public override void AppendUid(DicomUid uid) { string[] temp = new string[_values.Length + 1]; if (_values != null && _values.Length > 0) _values.CopyTo(temp, 0); _values = temp; _values[_values.Length - 1] = uid.UID; StreamLength = (uint)ToString().Length; Count = _values.Length; }
/// <summary> /// Set a UI attribute value base on the content of the DicomUid object. /// /// </summary> /// <param name="index"></param> /// <param name="value"></param> /// <exception cref="IndexOutOfBoundException">If <i>index</i> is less than 0 or greater than <seealso cref="Count"/></exception> /// <remarks> /// If <i>index</i> equals to <seealso cref="Count"/>, this method behaves exactly as <seealso cref="AppendUid"/> /// </remarks> public override void SetUid(int index, DicomUid value) { if (index == _values.Length) { AppendUid(value); } else { _values[index] = value.UID; StreamLength = (uint)ToString().Length; } }
/// <summary> /// Method to retrieve a DicomUI value from a UI attribute. /// /// </summary> /// <param name="i"></param> /// <param name="value">DicomUI object encapsulating the UI value</param> /// <returns><i>true</i>if value can be retrieved. <i>false</i> otherwise (see remarks)</returns> /// <remarks> /// This method returns <i>false</i> if /// If the value doesn't exist /// /// If the method returns false, the returned <i>value</i> should not be trusted. /// /// Returned DicomUI object may be different from the DicomUI that's set using <seealso cref="SetUid"/> or <seealso cref="AppendUid"/> /// Only the UID property of the DicomUI will be the same. /// /// </remarks> public override bool TryGetUid(int i, out DicomUid value) { if (i < 0 || i >= Count || _values.Length == 0) { value = null; return false; } if (string.IsNullOrEmpty(_values[i])) { value = null; return true; // this is special case } SopClass sop = SopClass.GetSopClass(_values[i]); if (sop != null) { value = sop.DicomUid; return true; } TransferSyntax ts = TransferSyntax.GetTransferSyntax(_values[i]); if (ts != null) { value = ts.DicomUid; return true; } value = new DicomUid(_values[i], _values[i], UidType.Unknown); return true; }
public static DicomUid Lookup(string uid) { DicomUid o = null; Entries.TryGetValue(uid, out o); if (o == null) { o = new DicomUid(uid, "Unknown UID", UidType.Unknown); } return o; }