-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy pathGenericComposite.cs
More file actions
64 lines (57 loc) · 2.15 KB
/
GenericComposite.cs
File metadata and controls
64 lines (57 loc) · 2.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
namespace NHapi.Base.Model
{
using System.Collections;
using System.Collections.Generic;
/// <summary>
/// An unspecified Composite datatype that has an undefined number of components, each
/// of which is a Varies.
/// This is used to store Varies data, when the data type is unknown. It is also
/// used to store unrecognized message constituents.
/// </summary>
/// <author>Bryan Tripp.</author>
public class GenericComposite : AbstractType, IComposite
{
private readonly List<IType> components;
/// <summary>
/// Creates a new instance of GenericComposite.
/// </summary>
/// <param name="theMessage">message to which this Type belongs.</param>
public GenericComposite(IMessage theMessage)
: this(theMessage, null)
{
}
/// <summary>
/// Creates a new instance of GenericComposite.
/// </summary>
/// <param name="theMessage">message to which this Type belongs.</param>
/// <param name="description">The description of this type.</param>
public GenericComposite(IMessage theMessage, string description)
: base(theMessage, description)
{
components = new List<IType>(20);
}
/// <summary>
/// Returns an array containing the components of this field.
/// </summary>
public virtual IType[] Components => components.ToArray();
/// <summary>
/// Returns the name of the type (used in XML encoding and profile checking).
/// </summary>
public override string TypeName => "UNKNOWN";
/// <summary>
/// Returns the single component of this composite at the specified position (starting at 0) -
/// Creates it (and any nonexistent components before it) if necessary.
/// </summary>
public virtual IType this[int index]
{
get
{
for (var i = components.Count; i <= index; i++)
{
components.Add(new Varies(Message));
}
return components[index];
}
}
}
}