IListType
IListType is interface for list descriptions.
/// <summary>Describes a single dimension list</summary>
public interface IListType : IDataType, ICyclical, IRangeProvider<ulong>
{
/// <summary>Element type</summary>
IDataType Element { get; set; }
}
/// <summary>Interface for properties that describe range of elements.</summary>
public interface IRangeProvider<T> where T : struct
{
/// <summary>Minimum number of elements.</summary>
Nullable<T> MinLength { get; set; }
/// <summary>Maximum number of elements.</summary>
Nullable<T> MaxLength { get; set; }
}
IDataType └── IListType
ListType is the default implementation.
IListType listType = new ListType
{
Name = Identities.CreateNamespace("Namespace").AppendName("MyList").SetReadOnly(),
Annotations = { },
Description = "This fields contains name of the record",
Unassignable = true,
Referable = true,
Element = DataTypes.Int32.Instance
}.SetReadOnly();
Namespace.MyList : IListType └── Element = int : IIntegerType
ListTypeRequest is request for a list type when sub-requests are needed.
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create list request
ListTypeRequest listRequest = new ListTypeRequest
{
Name = Identities.CreateName("MyList"),
Annotations = new Dictionary<string, string> { { IDataType.Annotation.Description, "This fields contains name of the record" } },
Unassignable = null,
Referable = null,
Element = new DataTypeRequest<NetType>(typeof(int))
};
// Request list
IListType listType = service.GetRequired<ListTypeRequest, IListType>(listRequest);
MyList : IListType └── Element = int : IIntegerType
Full Example
Full example
using System.Collections.Generic;
using Avalanche.DataType;
using Avalanche.Identity;
using Avalanche.Service;
using Avalanche.Utilities;
using static System.Console;
public class listtype
{
public static void Run()
{
{
// <01>
IListType listType = new ListType
{
Name = Identities.CreateNamespace("Namespace").AppendName("MyList").SetReadOnly(),
Annotations = { },
Description = "This fields contains name of the record",
Unassignable = true,
Referable = true,
Element = DataTypes.Int32.Instance
}.SetReadOnly();
// </01>
// Print
WriteLine(listType.PrintTree());
}
{
// <03>
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create list request
ListTypeRequest listRequest = new ListTypeRequest
{
Name = Identities.CreateName("MyList"),
Annotations = new Dictionary<string, string> { { IDataType.Annotation.Description, "This fields contains name of the record" } },
Unassignable = null,
Referable = null,
Element = new DataTypeRequest<NetType>(typeof(int))
};
// Request list
IListType listType = service.GetRequired<ListTypeRequest, IListType>(listRequest);
// </03>
// Print
WriteLine(listType.PrintTree());
}
}
}