/// <summary> /// Adds a single attribute with the tag sequence, VR and value specified. /// </summary> /// <remarks> /// Only use this method for setting an attribute with VR OB, OF or OW. /// <br></br><br></br> /// If an attribute already exists with this tag, it is removed first before it is again /// added. /// <br></br><br></br> /// If sequence items (each with a sequence item index) are specified in the tag sequence, /// empty sequence items will be added automatically to avoid gaps in the sequence items of sequence /// attributes. /// </remarks> /// <param name="tagSequence">The tag sequence of the attribute.</param> /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param> /// <param name="value">The value of the attribute.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="dvtkDataTag"/> is not valid for setting an attribute.<br></br> /// -or-<br></br> /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br> /// -or-<br></br> /// <paramref name="vR"/> is unequal to OB, OF or OW. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is a null reference. /// </exception> public override void Set(String tagSequence, VR vR, Byte[] value) { TagSequence internalTagSequence = new TagSequence(tagSequence); // // Sanity checks. // if (!internalTagSequence.IsSingleAttributeMatching) { throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting an attribute."); } // Check if the tag supplied is valid for a CommandSet. if (!internalTagSequence.IsValidForCommandSet) { throw new ArgumentException(internalTagSequence.ToString() + " not valid for setting a CommandSet attribute.", "dvtkDataTag"); } // Check the supplied VR. if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW)) { throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR"); } if (value == null) { throw new ArgumentNullException("value"); } // // Perform the actual operation in the base class. // Set(internalTagSequence, vR, value); }
/// <summary> /// Adds a single attribute with the tag, VR and value specified. /// </summary> /// <remarks> /// Only use this method for setting an attribute with VR OB, OF or OW. /// <br></br><br></br> /// If an attribute already exists with this tag, it is removed first before it is again /// added. /// </remarks> /// <param name="dvtkDataTag">The tag of the attribute.</param> /// <param name="vR">The VR (may only be OB, OF or OW) of the attribute.</param> /// <param name="value">The value of the attribute.</param> /// <exception cref="System.ArgumentException"> /// <paramref name="dvtkDataTag"/> is not valid for setting a CommandSet attribute.<br></br> /// -or-<br></br> /// <paramref name="vR"/> is unequal to OB, OF or OW. /// </exception> /// <exception cref="System.ArgumentNullException"> /// <paramref name="value"/> is a null reference. /// </exception> public override void Set(DvtkData.Dimse.Tag dvtkDataTag, VR vR, Byte[] value) { TagSequence internalTagSequence = new TagSequence(); internalTagSequence.Add(new Tag(dvtkDataTag.GroupNumber, dvtkDataTag.ElementNumber)); // // Sanity checks. // // Check if the tag supplied is valid for a CommandSet. if (!internalTagSequence.IsValidForCommandSet) { throw new ArgumentException(internalTagSequence.ToString() + " is not valid for setting a CommandSet attribute.", "dvtkDataTag"); } // Check the supplied VR. if ((vR != VR.OB) && (vR != VR.OF) && (vR != VR.OW)) { throw new ArgumentException("Supplied VR is " + vR.ToString() + ". VR may only be OB, OF or OW.", "vR"); } if (value == null) { throw new ArgumentNullException("value"); } // // Perform the actual operation in the base class. // Set(internalTagSequence, vR, value); }
/// <summary> /// Check if the supplied parameters correspond with the supplied VR. /// This functionality is used in e.g. the Append method. /// If the check fails, an exception is thrown. /// /// For now, the only check performed is looking if the supplied parameters /// are SequenceItems or not. /// </summary> /// <param name="vR">The VR.</param> /// <param name="parameters">The parameters.</param> internal void CheckParameters(VR vR, ICollection parameters) { int numberOfSequenceItems = 0; int numberOfNonSequenceItems = 0; foreach (Object parameter in parameters) { if (parameter is SequenceItem) { numberOfSequenceItems++; } else { numberOfNonSequenceItems++; } } if (vR == VR.SQ) { if (numberOfNonSequenceItems > 0) { throw new System.Exception(numberOfNonSequenceItems.ToString() + " non SequenceItems supplied for VR " + vR.ToString() + "."); } } else { if (numberOfSequenceItems > 0) { throw new System.Exception(numberOfSequenceItems.ToString() + " SequenceItems supplied for VR " + vR.ToString() + "."); } } }