Class ValueElement
Namespace: Aspose.Medical.Dicom.Elements
Assembly: Aspose.Medical.dll (25.11.0)
Encapsulates basic functionality for non text VR types (VR types that use .NET structures as underlying value type and ‘Attribute Tag’ VR).
public abstract class ValueElement<t> : IElementType Parameters
T
Value Type.
Inheritance
Implements
Inherited Members
object.GetType() , object.MemberwiseClone() , object.ToString() , object.Equals(object?) , object.Equals(object?, object?) , object.ReferenceEquals(object?, object?) , object.GetHashCode()
Constructors
ValueElement(Tag, Span<t>, ValueRepresentation, bool)
Initializes a new instance of the Aspose.Medical.Dicom.Elements.ValueElement`1.
protected ValueElement(Tag tag, Span<t> data, ValueRepresentation vr, bool skipValidation = false)Parameters
tag Tag
Element’s tag.
data Span
<t>
Element’s values.
Value Representation of a Value Element.
skipValidation bool
Indicates whether the validation should be skipped (if true) or not.
Exceptions
The provided data are invalid.
Properties
Count
The number of elements contained in this element. Read-only System.Int32.
public int Count { get; }Property Value
Data
Data of the element.
Read-only System.Collections.Generic.IReadOnlyCollection`1 of T.
public T[] Data { get; }Property Value
T[]
Tag
The DICOM tag associated with the element. Read-only Aspose.Medical.Dicom.Elements.IElement.Tag.
public Tag Tag { get; }Property Value
ValueRepresentation
The Value Representation of the element. Read-only Aspose.Medical.Dicom.Elements.IElement.ValueRepresentation.
public abstract ValueRepresentation ValueRepresentation { get; }Property Value
Methods
Accept(Walker)
Dispatches (delegates) a request to the accepted walker.
protected abstract void Accept(Walker walker)Parameters
walker Walker
A walker to be used for traversal and perform operations.
AcceptAsync(AsyncWalker)
Asynchronously dispatches (delegates) a request to the accepted walker.
protected abstract Task AcceptAsync(AsyncWalker walker)Parameters
walker AsyncWalker
A walker to be used for traversal and perform operations.
Returns
Add(T)
Adds the given value to the collection of values of this element.
public void Add(T value)Parameters
value T
A value to be added to this element.
Exceptions
Number of values does not match Value Multiplicity.
AddRange(Span<t>)
Adds the given values to the collection of values of this element.
public void AddRange(Span<t> values)Parameters
values Span
<t>
Values to be added to this element.
Exceptions
Number of values does not match Value Multiplicity.
ConvertData<toutput>(Func<t, toutput="">)
Converts the element data to the specified type and returns the converted data.
public Span<toutput> ConvertData<toutput>(Func<t, toutput=""> converter)Parameters
converter Func
<t, toutput="">
Function to be applied to convert element’s data.
Returns
Span <toutput>
The converted data.
Type Parameters
TOutput
Target type the element data to be converted.
Get<tvalue>(int)
Returns the element’s value at the specified position.
public TValue Get<tvalue>(int index)Parameters
index int
The zero-based index of the element to retrieve.
Returns
TValue
The T value.
Type Parameters
TValue
Exceptions
index is less than 0; index equal to or greater than Aspose.Medical.Dicom.Elements.ValueElement`1.Count.
Unable to convert element value to the specified type.
Get<tvalue>(Index)
Returns the element’s value at the specified position.
public TValue Get<tvalue>(Index index)Parameters
index Index
The index of the element value to retrieve, which is either from the beginning or the end of the sequence.
Returns
TValue
The T value.
Type Parameters
TValue
Exceptions
index is less than 0; index equal to or greater than Aspose.Medical.Dicom.Elements.ValueElement`1.Count.
Unable to convert element value to target type.
Get(int)
Gets the element value stored at the given position.
public T Get(int index = 0)Parameters
index int
Returns
T
The T element value.
Exceptions
index is less than 0 or index is equal to or greater than Aspose.Medical.Dicom.Elements.ValueElement`1.Count.
GetOrDefault<tvalue>(int)
Returns the element’s value at the specified position or a default value if the index is out of range.
public TValue? GetOrDefault<tvalue>(int index)Parameters
index int
The zero-based index of the element value to retrieve.
Returns
TValue?
The T value.
Type Parameters
TValue
Exceptions
Unable to convert element value to target type.
GetOrDefault<tvalue>(Index)
Returns the element’s value at the specified position or a default value if the index is out of range.
public TValue? GetOrDefault<tvalue>(Index index)Parameters
index Index
The index of the element value to retrieve, which is either from the beginning or the end of the sequence.
Returns
TValue?
The T value.
Type Parameters
TValue
Exceptions
Unable to convert element value to the specified type.
GetSingleOrDefault()
Gets the element value, whose value multiplicity has to be 1.
public T? GetSingleOrDefault()Returns
T?
The T element value.
GetValues<tvalue>()
Returns the element’s values.
public Span<tvalue> GetValues<tvalue>()Returns
Span <tvalue>
The element’s data.
Type Parameters
TValue
GetValues()
Returns the element’s values.
public Span<t> GetValues()Returns
Span <t>
The element’s data.
GetValues<tvalue>(Range)
Returns the element’s values at the specified range.
public Span<tvalue> GetValues<tvalue>(Range range)Parameters
range Range
The range of the element values to retrieve.
Returns
Span <tvalue>
The element’s data.
Type Parameters
TValue
GetValues(Range)
Returns the element’s values at the specified range.
public Span<t> GetValues(Range range)Parameters
range Range
The range of the element values to retrieve.
Returns
Span <t>
The element’s data.
Insert(int, T)
Inserts the given value into
this element at a given index.
The size of the list is increased by one.
public void Insert(int index, T value)Parameters
index int
The zero-based index at which value should be inserted.
value T
A value to be inserted at the specified index.
Exceptions
Number of values does not match Value Multiplicity.
Remove(T)
Removes the first occurrence of a specific value from the element.
public bool Remove(T value)Parameters
value T
The object to remove from the element.
Returns
true if value is successfully removed; otherwise, false. This method also returns false if value was not found in the element.
Exceptions
Number of values does not match Value Multiplicity.
RemoveAt(int)
Removes the value at the specified index of the element.
public void RemoveAt(int index)Parameters
index int
The zero-based index of the element to remove.
Exceptions
Number of values does not match Value Multiplicity.
Replace(IEnumerable<t>)
Replaces the current values by the collection of the given values.
public void Replace(IEnumerable<t> values)Parameters
values IEnumerable
<t>
Values to be set to this element.
Exceptions
Number of values does not match Value Multiplicity.
ToString()
public override string ToString()Returns
TryGetValue<tvalue>(int, out TValue?)
Gets the element’s value at the specified position.
public bool TryGetValue<tvalue>(int index, out TValue? value)Parameters
index int
The index of the element value to retrieve, which is either from the beginning or the end of the sequence.
value TValue?
When this method returns, contains the value at the specified position (index);
otherwise, contains the default value for the type of the value parameter.
Returns
true if the element value could be extracted; otherwise, false.
Type Parameters
TValue
Exceptions
Unable to convert element value to target type.
TryGetValue<tvalue>(Index, out TValue?)
Gets the element’s value at the specified position.
public bool TryGetValue<tvalue>(Index index, out TValue? value)Parameters
index Index
The index of the element value to retrieve, which is either from the beginning or the end of the sequence.
value TValue?
When this method returns, contains the value at the specified position (index);
otherwise, contains the default value for the type of the value parameter.
Returns
true if the element value could be extracted; otherwise, false.
Type Parameters
TValue
Exceptions
Unable to convert element value to target type. </tvalue></tvalue></t></t></t></tvalue></tvalue></t></tvalue></tvalue></tvalue></tvalue></tvalue></tvalue></toutput></t,></t,></t,></toutput></t></t></t></t></t>