mirror of
https://github.com/actions/runner.git
synced 2025-12-18 16:26:58 +00:00
55 lines
1.9 KiB
C#
55 lines
1.9 KiB
C#
using System;
|
|
using GitHub.DistributedTask.ObjectTemplating.Tokens;
|
|
|
|
namespace GitHub.DistributedTask.ObjectTemplating.Schema
|
|
{
|
|
internal sealed class NumberDefinition : ScalarDefinition
|
|
{
|
|
internal NumberDefinition()
|
|
{
|
|
}
|
|
|
|
internal NumberDefinition(MappingToken definition)
|
|
: base(definition)
|
|
{
|
|
foreach (var definitionPair in definition)
|
|
{
|
|
var definitionKey = definitionPair.Key.AssertString($"{TemplateConstants.Definition} key");
|
|
switch (definitionKey.Value)
|
|
{
|
|
case TemplateConstants.Number:
|
|
var mapping = definitionPair.Value.AssertMapping($"{TemplateConstants.Definition} {TemplateConstants.Number}");
|
|
foreach (var mappingPair in mapping)
|
|
{
|
|
var mappingKey = mappingPair.Key.AssertString($"{TemplateConstants.Definition} {TemplateConstants.Number} key");
|
|
switch (mappingKey.Value)
|
|
{
|
|
default:
|
|
mappingKey.AssertUnexpectedValue($"{TemplateConstants.Definition} {TemplateConstants.Number} key");
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
|
|
default:
|
|
definitionKey.AssertUnexpectedValue($"{TemplateConstants.Definition} key");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
internal override DefinitionType DefinitionType => DefinitionType.Number;
|
|
|
|
internal override Boolean IsMatch(LiteralToken literal)
|
|
{
|
|
return literal is NumberToken;
|
|
}
|
|
|
|
internal override void Validate(
|
|
TemplateSchema schema,
|
|
String name)
|
|
{
|
|
}
|
|
}
|
|
}
|