SchemaBase Class
Base implementation for a based schema.
public abstract class SchemaBase : IYamlSchema- Implements
Constructors
| Name | Description |
|---|---|
| SchemaBase() |
SchemaBase()
SchemaBase.csprotected SchemaBase()No documentation is available.
Methods
| Name | Description |
|---|---|
| AddScalarRule(Type[], string, string, Func<Match, object?>, Func<object, string>?) | Adds a scalar resolution rule for one or more CLR types. |
| AddScalarRule<T>(string, string, Func<Match, T?>, Func<T, string>?) | Add a tag resolution rule that is invoked when regex matches the Value of a Scalar node. The tag is resolved to tag and decode is invoked when actual value of type T is extracted from the node text. |
| ExpandTag(string?) | Expands a short tag into its long form. |
| GetDefaultTag(MappingStart) | Gets the default tag for a MappingStart event. |
| GetDefaultTag(NodeEvent) | Gets default Tag. |
| GetDefaultTag(SequenceStart) | Gets the default tag for a SequenceStart event. |
| GetDefaultTag(Type) | Gets default Tag. |
| GetTypeForDefaultTag(string?) | Gets type For Default Tag. |
| IsTagImplicit(string?) | Determines whether tag Implicit. |
| PrepareScalarRules() | Prepare scalar rules. In the implementation of this method, should call |
| RegisterDefaultTagMapping(string, Type, bool) | Registers a default tag mapping for the specified CLR type. |
| RegisterDefaultTagMapping<T>(string, bool) | Registers a default tag mapping for T. |
| RegisterTag(string, string) | Registers a long/short tag association. |
| ShortenTag(string?) | Converts a long tag into its short form. |
| TryParse(Scalar, bool, string?, object?) | Tries to parse. |
| TryParse(Scalar, Type, object?) | Tries to parse. |
AddScalarRule overloads
AddScalarRule(Type[], string, string, Func<Match, object?>, Func<object, string>?)
SchemaBase.csAddScalarRule<T>(string, string, Func<Match, T?>, Func<T, string>?)
SchemaBase.csAdd a tag resolution rule that is invoked when regex matches the Value of a Scalar node. The tag is resolved to tag and decode is invoked when actual value of type T is extracted from the node text.
protected void AddScalarRule<T>(string tag, string regex, Func<Match, T?> decode, Func<T, string>? encode)Type parameters
T- Type of the scalar
Parameters
tagstring- The tag.
regexstring- The regex.
decodeFunc<Match, T?>- The decode function.
encodeFunc<T, string>?- The encode function.
Example
private sealed class OnOffSchema : CoreSchema
{
protected override void PrepareScalarRules()
{
base.PrepareScalarRules();
// Resolve on/off as booleans, in addition to the rules of the core schema
AddScalarRule("!!bool", "on|On|ON", _ => true, null);
AddScalarRule("!!bool", "off|Off|OFF", _ => false, null);
}
}ExpandTag(string?)
SchemaBase.csGetDefaultTag overloads
GetDefaultTag(MappingStart)
Gets the default tag for a MappingStart event.
protected abstract string GetDefaultTag(MappingStart nodeEvent)GetDefaultTag(NodeEvent)
SchemaBase.csGetDefaultTag(SequenceStart)
Gets the default tag for a SequenceStart event.
protected abstract string GetDefaultTag(SequenceStart nodeEvent)GetDefaultTag(Type)
SchemaBase.csGetTypeForDefaultTag(string?)
SchemaBase.csIsTagImplicit(string?)
SchemaBase.csPrepareScalarRules()
SchemaBase.csPrepare scalar rules. In the implementation of this method, should call
protected virtual void PrepareScalarRules()RegisterDefaultTagMapping overloads
RegisterDefaultTagMapping(string, Type, bool)
SchemaBase.csRegisterDefaultTagMapping<T>(string, bool)
SchemaBase.csRegisterTag(string, string)
SchemaBase.csShortenTag(string?)
SchemaBase.csTryParse overloads
TryParse(Scalar, bool, string?, object?)
SchemaBase.csTryParse(Scalar, Type, object?)
SchemaBase.csConstants
| Name | Description |
|---|---|
| StrLongTag | The string long tag: tag:yaml.org,2002:str |
| StrShortTag | The string short tag: !!str |
StrLongTag
The string long tag: tag:yaml.org,2002:str
public const string StrLongTag = "tag:yaml.org,2002:str"StrShortTag
The string short tag: !!str
public const string StrShortTag = "!!str"