Import YamlDotNet.

This commit is contained in:
2022-12-12 22:23:49 +08:00
parent f559cea826
commit 1477e907e6
462 changed files with 27142 additions and 0 deletions

8
Assets/YamlDotNet.meta Normal file
View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 9a19996d4b24ff14f99f7b17e0b45ecf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: cbe04dd6a5622cf4fb8a12e664da340d
folderAsset: yes
timeCreated: 1427145262
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,76 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Text.RegularExpressions;
namespace YamlDotNet.Core
{
public struct AnchorName : IEquatable<AnchorName>
{
public static readonly AnchorName Empty = default;
// https://yaml.org/spec/1.2/spec.html#id2785586
private static readonly Regex AnchorPattern = new Regex(@"^[^\[\]\{\},]+$", StandardRegexOptions.Compiled);
private readonly string? value;
public string Value => value ?? throw new InvalidOperationException("Cannot read the Value of an empty anchor");
public bool IsEmpty => value is null;
public AnchorName(string value)
{
this.value = value ?? throw new ArgumentNullException(nameof(value));
if (!AnchorPattern.IsMatch(value))
{
throw new ArgumentException($"Anchor cannot be empty or contain disallowed characters: []{{}},\nThe value was '{value}'.", nameof(value));
}
}
public override string ToString() => value ?? "[empty]";
public bool Equals(AnchorName other) => Equals(value, other.value);
public override bool Equals(object? obj)
{
return obj is AnchorName other && Equals(other);
}
public override int GetHashCode()
{
return value?.GetHashCode() ?? 0;
}
public static bool operator ==(AnchorName left, AnchorName right)
{
return left.Equals(right);
}
public static bool operator !=(AnchorName left, AnchorName right)
{
return !(left == right);
}
public static implicit operator AnchorName(string? value) => value == null ? Empty : new AnchorName(value);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4b743e73dd5df19488bf7108b4a7e5a8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,58 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
namespace YamlDotNet.Core
{
/// <summary>
/// The exception that is thrown when an alias references an anchor that does not exist.
/// </summary>
public class AnchorNotFoundException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public AnchorNotFoundException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
public AnchorNotFoundException(Mark start, Mark end, string message)
: base(start, end, message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="inner">The inner.</param>
public AnchorNotFoundException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: bef940054d2c25041ba1a961abae6c79
timeCreated: 1427145266
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,166 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
using System.Diagnostics;
namespace YamlDotNet.Core
{
internal sealed class CharacterAnalyzer<TBuffer> where TBuffer : class, ILookAheadBuffer
{
public CharacterAnalyzer(TBuffer buffer)
{
this.Buffer = buffer ?? throw new ArgumentNullException(nameof(buffer));
}
public TBuffer Buffer { get; }
public bool EndOfInput => Buffer.EndOfInput;
public char Peek(int offset)
{
return Buffer.Peek(offset);
}
public void Skip(int length)
{
Buffer.Skip(length);
}
public bool IsAlphaNumericDashOrUnderscore(int offset = 0)
{
var character = Buffer.Peek(offset);
return
(character >= '0' && character <= '9') ||
(character >= 'A' && character <= 'Z') ||
(character >= 'a' && character <= 'z') ||
character == '_' ||
character == '-';
}
public bool IsAscii(int offset = 0)
{
return Buffer.Peek(offset) <= '\x7F';
}
public bool IsPrintable(int offset = 0)
{
var character = Buffer.Peek(offset);
return
character == '\x9' ||
character == '\xA' ||
character == '\xD' ||
(character >= '\x20' && character <= '\x7E') ||
character == '\x85' ||
(character >= '\xA0' && character <= '\xD7FF') ||
(character >= '\xE000' && character <= '\xFFFD');
}
public bool IsDigit(int offset = 0)
{
var character = Buffer.Peek(offset);
return character >= '0' && character <= '9';
}
public int AsDigit(int offset = 0)
{
return Buffer.Peek(offset) - '0';
}
public bool IsHex(int offset)
{
var character = Buffer.Peek(offset);
return
(character >= '0' && character <= '9') ||
(character >= 'A' && character <= 'F') ||
(character >= 'a' && character <= 'f');
}
public int AsHex(int offset)
{
var character = Buffer.Peek(offset);
if (character <= '9')
{
return character - '0';
}
if (character <= 'F')
{
return character - 'A' + 10;
}
return character - 'a' + 10;
}
public bool IsSpace(int offset = 0)
{
return Check(' ', offset);
}
public bool IsZero(int offset = 0)
{
return Check('\0', offset);
}
public bool IsTab(int offset = 0)
{
return Check('\t', offset);
}
public bool IsWhite(int offset = 0)
{
return IsSpace(offset) || IsTab(offset);
}
public bool IsBreak(int offset = 0)
{
return Check("\r\n\x85\x2028\x2029", offset);
}
public bool IsCrLf(int offset = 0)
{
return Check('\r', offset) && Check('\n', offset + 1);
}
public bool IsBreakOrZero(int offset = 0)
{
return IsBreak(offset) || IsZero(offset);
}
public bool IsWhiteBreakOrZero(int offset = 0)
{
return IsWhite(offset) || IsBreakOrZero(offset);
}
public bool Check(char expected, int offset = 0)
{
return Buffer.Peek(offset) == expected;
}
public bool Check(string expectedCharacters, int offset = 0)
{
// Todo: using it this way doesn't break anything, it's not really wrong...
Debug.Assert(expectedCharacters.Length > 1, "Use Check(char, int) instead.");
var character = Buffer.Peek(offset);
return expectedCharacters.IndexOf(character) != -1;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: cdb65e878b6f92347849551efad9eb74
timeCreated: 1427145266
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,40 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using YamlDotNet.Core.Tokens;
namespace YamlDotNet.Core
{
/// <summary>
/// Defines constants that relate to the YAML specification.
/// </summary>
public static class Constants
{
public static readonly TagDirective[] DefaultTagDirectives =
{
new TagDirective("!", "!"),
new TagDirective("!!", "tag:yaml.org,2002:")
};
public const int MajorVersion = 1;
public const int MinorVersion = 3;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6143f3f95b0bcb74c92b9996309fab40
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,69 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core
{
public sealed class Cursor
{
public int Index { get; private set; }
public int Line { get; private set; }
public int LineOffset { get; private set; }
public Cursor()
{
Line = 1;
}
public Cursor(Cursor cursor)
{
Index = cursor.Index;
Line = cursor.Line;
LineOffset = cursor.LineOffset;
}
public Mark Mark()
{
return new Mark(Index, Line, LineOffset + 1);
}
public void Skip()
{
Index++;
LineOffset++;
}
public void SkipLineByOffset(int offset)
{
Index += offset;
Line++;
LineOffset = 0;
}
public void ForceSkipLineAfterNonBreak()
{
if (LineOffset != 0)
{
Line++;
LineOffset = 0;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b4262bdec0f3c254b9a29e755ba3a609
timeCreated: 1427145265
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: f526134efcd8e424c86e492f85fc56ba
timeCreated: 1427145267
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,159 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using System;
namespace YamlDotNet.Core
{
public sealed class EmitterSettings
{
/// <summary>
/// The preferred indentation.
/// </summary>
public int BestIndent { get; } = 2;
/// <summary>
/// The preferred text width.
/// </summary>
public int BestWidth { get; } = int.MaxValue;
/// <summary>
/// If true, write the output in canonical form.
/// </summary>
public bool IsCanonical { get; } = false;
/// <summary>
/// If true, write output without anchor names.
/// </summary>
public bool SkipAnchorName { get; private set; }
/// <summary>
/// The maximum allowed length for simple keys.
/// </summary>
/// <remarks>
/// The specifiction mandates 1024 characters, but any desired value may be used.
/// </remarks>
public int MaxSimpleKeyLength { get; } = 1024;
/// <summary>
/// Indent sequences. The default is to not indent.
/// </summary>
public bool IndentSequences { get; } = false;
public static readonly EmitterSettings Default = new EmitterSettings();
public EmitterSettings()
{
}
public EmitterSettings(int bestIndent, int bestWidth, bool isCanonical, int maxSimpleKeyLength, bool skipAnchorName = false, bool indentSequences = false)
{
if (bestIndent < 2 || bestIndent > 9)
{
throw new ArgumentOutOfRangeException(nameof(bestIndent), $"BestIndent must be between 2 and 9, inclusive");
}
if (bestWidth <= bestIndent * 2)
{
throw new ArgumentOutOfRangeException(nameof(bestWidth), "BestWidth must be greater than BestIndent x 2.");
}
if (maxSimpleKeyLength < 0)
{
throw new ArgumentOutOfRangeException(nameof(maxSimpleKeyLength), "MaxSimpleKeyLength must be >= 0");
}
BestIndent = bestIndent;
BestWidth = bestWidth;
IsCanonical = isCanonical;
MaxSimpleKeyLength = maxSimpleKeyLength;
SkipAnchorName = skipAnchorName;
IndentSequences = indentSequences;
}
public EmitterSettings WithBestIndent(int bestIndent)
{
return new EmitterSettings(
bestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithBestWidth(int bestWidth)
{
return new EmitterSettings(
BestIndent,
bestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithMaxSimpleKeyLength(int maxSimpleKeyLength)
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
maxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings Canonical()
{
return new EmitterSettings(
BestIndent,
BestWidth,
true,
MaxSimpleKeyLength,
SkipAnchorName
);
}
public EmitterSettings WithoutAnchorName()
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
true
);
}
public EmitterSettings WithIndentedSequences()
{
return new EmitterSettings(
BestIndent,
BestWidth,
IsCanonical,
MaxSimpleKeyLength,
SkipAnchorName,
true
);
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7496371f913cd4a4aa6e1d7009a88169
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core
{
internal enum EmitterState
{
StreamStart,
StreamEnd,
FirstDocumentStart,
DocumentStart,
DocumentContent,
DocumentEnd,
FlowSequenceFirstItem,
FlowSequenceItem,
FlowMappingFirstKey,
FlowMappingKey,
FlowMappingSimpleValue,
FlowMappingValue,
BlockSequenceFirstItem,
BlockSequenceItem,
BlockMappingFirstKey,
BlockMappingKey,
BlockMappingSimpleValue,
BlockMappingValue
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7127212075b19ce4f99a370f02d26037
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 2dd1df9756078164587ab6fc3579145d
folderAsset: yes
timeCreated: 1427145262
licenseType: Store
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,85 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
/// <summary>
/// Represents an alias event.
/// </summary>
public sealed class AnchorAlias : ParsingEvent
{
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type => EventType.Alias;
/// <summary>
/// Gets the value of the alias.
/// </summary>
public AnchorName Value { get; }
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public AnchorAlias(AnchorName value, Mark start, Mark end)
: base(start, end)
{
if (value.IsEmpty)
{
throw new YamlException(start, end, "Anchor value must not be empty.");
}
this.Value = value;
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorAlias"/> class.
/// </summary>
/// <param name="value">The value of the alias.</param>
public AnchorAlias(AnchorName value)
: this(value, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"Alias [value = {Value}]";
}
/// <summary>
/// Invokes run-time type specific Visit() method of the specified visitor.
/// </summary>
/// <param name="visitor">visitor, may not be null.</param>
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 09b29b54793d9644398fe8e4da326353
timeCreated: 1427145262
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,59 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
public sealed class Comment : ParsingEvent
{
public string Value { get; }
public bool IsInline { get; }
public Comment(string value, bool isInline)
: this(value, isInline, Mark.Empty, Mark.Empty)
{
}
public Comment(string value, bool isInline, Mark start, Mark end)
: base(start, end)
{
Value = value;
IsInline = isInline;
}
internal override EventType Type => EventType.Comment;
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"{(IsInline ? "Inline" : "Block")} Comment [{Value}]";
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: e96511072ac5a30488623987ca605570
timeCreated: 1427145267
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,90 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
/// <summary>
/// Represents a document end event.
/// </summary>
public sealed class DocumentEnd : ParsingEvent
{
/// <summary>
/// Gets a value indicating the variation of depth caused by this event.
/// The value can be either -1, 0 or 1. For start events, it will be 1,
/// for end events, it will be -1, and for the remaining events, it will be 0.
/// </summary>
public override int NestingIncrease => -1;
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type => EventType.DocumentEnd;
/// <summary>
/// Gets a value indicating whether this instance is implicit.
/// </summary>
/// <value>
/// <c>true</c> if this instance is implicit; otherwise, <c>false</c>.
/// </value>
public bool IsImplicit { get; }
/// <summary>
/// Initializes a new instance of the <see cref="DocumentEnd"/> class.
/// </summary>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public DocumentEnd(bool isImplicit, Mark start, Mark end)
: base(start, end)
{
this.IsImplicit = isImplicit;
}
/// <summary>
/// Initializes a new instance of the <see cref="DocumentEnd"/> class.
/// </summary>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
public DocumentEnd(bool isImplicit)
: this(isImplicit, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"Document end [isImplicit = {IsImplicit}]";
}
/// <summary>
/// Invokes run-time type specific Visit() method of the specified visitor.
/// </summary>
/// <param name="visitor">visitor, may not be null.</param>
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 99b4ea3b75d2e754cb5fea7cc0f1a4d3
timeCreated: 1427145265
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,128 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
using YamlDotNet.Core.Tokens;
namespace YamlDotNet.Core.Events
{
/// <summary>
/// Represents a document start event.
/// </summary>
public sealed class DocumentStart : ParsingEvent
{
/// <summary>
/// Gets a value indicating the variation of depth caused by this event.
/// The value can be either -1, 0 or 1. For start events, it will be 1,
/// for end events, it will be -1, and for the remaining events, it will be 0.
/// </summary>
public override int NestingIncrease => 1;
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type => EventType.DocumentStart;
/// <summary>
/// Gets the tags.
/// </summary>
/// <value>The tags.</value>
public TagDirectiveCollection? Tags { get; }
/// <summary>
/// Gets the version.
/// </summary>
/// <value>The version.</value>
public VersionDirective? Version { get; }
/// <summary>
/// Gets a value indicating whether this instance is implicit.
/// </summary>
/// <value>
/// <c>true</c> if this instance is implicit; otherwise, <c>false</c>.
/// </value>
public bool IsImplicit { get; }
/// <summary>
/// Initializes a new instance of the <see cref="DocumentStart"/> class.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="tags">The tags.</param>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public DocumentStart(VersionDirective? version, TagDirectiveCollection? tags, bool isImplicit, Mark start, Mark end)
: base(start, end)
{
this.Version = version;
this.Tags = tags;
this.IsImplicit = isImplicit;
}
/// <summary>
/// Initializes a new instance of the <see cref="DocumentStart"/> class.
/// </summary>
/// <param name="version">The version.</param>
/// <param name="tags">The tags.</param>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
public DocumentStart(VersionDirective? version, TagDirectiveCollection? tags, bool isImplicit)
: this(version, tags, isImplicit, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DocumentStart"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public DocumentStart(Mark start, Mark end)
: this(null, null, true, start, end)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DocumentStart"/> class.
/// </summary>
public DocumentStart()
: this(null, null, true, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </summary>
/// <returns>
/// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
/// </returns>
public override string ToString()
{
return $"Document start [isImplicit = {IsImplicit}]";
}
/// <summary>
/// Invokes run-time type specific Visit() method of the specified visitor.
/// </summary>
/// <param name="visitor">visitor, may not be null.</param>
public override void Accept(IParsingEventVisitor visitor)
{
visitor.Visit(this);
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 06cc13f1bc1622246924546d044eede9
timeCreated: 1427145262
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,39 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
internal enum EventType
{
None,
StreamStart,
StreamEnd,
DocumentStart,
DocumentEnd,
Alias,
Scalar,
SequenceStart,
SequenceEnd,
MappingStart,
MappingEnd,
Comment,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 3a7e249b62575e048929c7a3e0420470
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,41 @@
// This file is part of YamlDotNet - A .NET library for YAML.
// Copyright (c) Antoine Aubry and contributors
//
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
// of the Software, and to permit persons to whom the Software is furnished to do
// so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
namespace YamlDotNet.Core.Events
{
/// <summary>
/// Callback interface for external event Visitor.
/// </summary>
public interface IParsingEventVisitor
{
void Visit(AnchorAlias e);
void Visit(StreamStart e);
void Visit(StreamEnd e);
void Visit(DocumentStart e);
void Visit(DocumentEnd e);
void Visit(Scalar e);
void Visit(SequenceStart e);
void Visit(SequenceEnd e);
void Visit(MappingStart e);
void Visit(MappingEnd e);
void Visit(Comment e);
}
}

Some files were not shown because too many files have changed in this diff Show More