StringType
IStringType is a description of string types.
/// <summary>String type description</summary>
public interface IStringType : IListType
{
/// <summary>Keys for wellknown keys for <see cref="IDataType.Annotations"/>.</summary>
public static new class Annotation
{
/// <summary>Regex pattern for valid values.</summary>
public const string Pattern = nameof(Pattern);
/// <summary>Character encoding of this string type. e.g. "ASCII" "UTF-8" "UTF-16" "UTF-32"</summary>
public const string Encoding = nameof(Encoding);
}
}
IDataType └── IListType └── IStringType
StringType is the default implementation.
IStringType datatype = new StringType
{
Name = Identities.CreateName("string").SetReadOnly(),
Annotations = { },
Description = "String",
Unassignable = true,
Referable = true,
Element = DataTypes.Char.Instance
}.SetReadOnly();
IStringType { Name = "string" , Nullable = True, Referable = True, Description = "", Annotations = [], MinLength = 0, MaxLength = 2147483647 } └── Element = IIntegerType { Name = "char" , SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = , MinValue = 0, MaxValue = 65535 }
StringTypeRequest is request for a string type when sub-requests are needed.
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create request
StringTypeRequest request = new StringTypeRequest
{
Name = Identities.CreateName("string").SetReadOnly(),
Annotations = new Dictionary<string, string> { { IDataType.Annotation.Description, "String" } },
Unassignable = null,
Referable = null,
Element = new DataTypeRequest<NetType>(typeof(char))
};
// Query
IStringType datatype = service.GetRequired<IRequestFor<IStringType>, IStringType>(request);
IStringType { Name = "string" , Nullable = False, Referable = False, Annotations = [], MinLength = 0, MaxLength = 2147483647 } └── Element = IIntegerType { Name = "char" , SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = , MinValue = 0, MaxValue = 65535 }
DataTypeRequest<NetString> is a request for string type by Type. (Avalanche.DataType.Net.dll)
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create request
DataTypeRequest<NetType> request = new(typeof(string));
// Request record
IStringType datatype = service.GetRequired<DataTypeRequest<NetType>, IStringType>(request);
IStringType { Name = "string" , Encoding = "Unicode", Nullable = True, Referable = True, Description = "Unicode UTF-16", Annotations = [], MinLength = 0, MaxLength = 2147483647 } └── Element = IIntegerType { Name = "char" , SignCapability = False, Nullable = False, Referable = False, Annotations = [], DefaultValue = , MinValue = 0, MaxValue = 65535 }
DataTypes facade contains type definition for .NET type.
IStringType datatype0 = DataTypes.String.Instance;
Annotations
Well-known annotations.
Field | Key | Type | Description |
---|---|---|---|
IString.Annotation.Pattern | Pattern | string | Regex pattern for valid values. |
IString.Annotation.Encoding | Encoding | string | Character encoding of this string type. e.g. "ASCII" "UTF-8" "UTF-16" "UTF-32" |
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 stringtype
{
public static void Run()
{
{
// <01>
IStringType datatype = new StringType
{
Name = Identities.CreateName("string").SetReadOnly(),
Annotations = { },
Description = "String",
Unassignable = true,
Referable = true,
Element = DataTypes.Char.Instance
}.SetReadOnly();
// </01>
// Print
WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
}
{
// <03>
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create request
StringTypeRequest request = new StringTypeRequest
{
Name = Identities.CreateName("string").SetReadOnly(),
Annotations = new Dictionary<string, string> { { IDataType.Annotation.Description, "String" } },
Unassignable = null,
Referable = null,
Element = new DataTypeRequest<NetType>(typeof(char))
};
// Query
IStringType datatype = service.GetRequired<IRequestFor<IStringType>, IStringType>(request);
// </03>
// Print
WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
}
{
// <04>
// Create service
IService service = Services.Create(NetTypeHandlers.Instance);
// Create request
DataTypeRequest<NetType> request = new(typeof(string));
// Request record
IStringType datatype = service.GetRequired<DataTypeRequest<NetType>, IStringType>(request);
// </04>
// Print
WriteLine(datatype.PrintTree(format: DataTypePrintTreeExtensions.PrintFormat.DefaultLong));
}
{
// <05>
IStringType datatype0 = DataTypes.String.Instance;
// </05>
}
}
}