IMapType
IMapType is interface for map descriptions.
/// <summary>Map type description.</summary>
public interface IMapType : IDataType, ICyclical
{
/// <summary>Key type</summary>
IDataType Key { get; set; }
/// <summary>Value type</summary>
IDataType Value { get; set; }
}
IDataType └── IMapType
MapType is the default implementation.
IMapType mapType = new MapType
{
Name = Identities.CreateNamespace("Namespace").AppendName("MyMap").SetReadOnly(),
Properties = { },
Description = "Map type",
Unassignable = true,
Referable = true,
Key = DataTypes.String.Instance,
Value = DataTypes.Int32.Instance
}.SetReadOnly();
Namespace.MyMap : IMapType ├── Key = string : IStringType │ └── Element = char : IIntegerType └── Value = int : IIntegerType
MapTypeRequest is request for a map type when sub-requests are needed.
// Create service
IService service = Services.Create(Avalanche.DataType.Dto.Module.Instance);
// Create map request
MapTypeRequest mapRequest = new MapTypeRequest
{
Name = Identities.CreateName("MyMap"),
Properties = new Dictionary<string, string> { { IDataType.Property.Description, "Map type" } },
Unassignable = null,
Referable = null,
Key = new DataTypeRequest(new DtoTarget(typeof(string))),
Value = new DataTypeRequest(new DtoTarget(typeof(int)))
};
// Request map
IMapType mapType = service.GetRequired<MapTypeRequest, IMapType>(mapRequest);
MyMap : IMapType ├── Key = string : IStringType │ └── Element = char : IIntegerType └── Value = int : IIntegerType
Full Example
Full example
using System.Collections.Concurrent;
using System.Collections.Generic;
using Avalanche.DataType;
using Avalanche.Identity;
using Avalanche.Service;
using Avalanche.Utilities;
using static System.Console;
public class maptype
{
public static void Run()
{
{
// <01>
IMapType mapType = new MapType
{
Name = Identities.CreateNamespace("Namespace").AppendName("MyMap").SetReadOnly(),
Properties = { },
Description = "Map type",
Unassignable = true,
Referable = true,
Key = DataTypes.String.Instance,
Value = DataTypes.Int32.Instance
}.SetReadOnly();
// </01>
// Print
WriteLine(mapType.PrintTree());
}
{
// <03>
// Create service
IService service = Services.Create(Avalanche.DataType.Dto.Module.Instance);
// Create map request
MapTypeRequest mapRequest = new MapTypeRequest
{
Name = Identities.CreateName("MyMap"),
Properties = new Dictionary<string, string> { { IDataType.Property.Description, "Map type" } },
Unassignable = null,
Referable = null,
Key = new DataTypeRequest(new DtoTarget(typeof(string))),
Value = new DataTypeRequest(new DtoTarget(typeof(int)))
};
// Request map
IMapType mapType = service.GetRequired<MapTypeRequest, IMapType>(mapRequest);
// </03>
// Print
WriteLine(mapType.PrintTree());
}
}
}