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);
}
}

View File

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

View File

@@ -0,0 +1,79 @@
// 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 mapping end event.
/// </summary>
public class MappingEnd : 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.MappingEnd;
/// <summary>
/// Initializes a new instance of the <see cref="MappingEnd"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public MappingEnd(Mark start, Mark end)
: base(start, end)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MappingEnd"/> class.
/// </summary>
public MappingEnd()
: this(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 "Mapping end";
}
/// <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: 32f12dd96a8cb4d4792ed76749f67b38
timeCreated: 1427145263
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,116 @@
// 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 mapping start event.
/// </summary>
public sealed class MappingStart : NodeEvent
{
/// <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.MappingStart;
/// <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>
/// Gets a value indicating whether this instance is canonical.
/// </summary>
/// <value></value>
public override bool IsCanonical => !IsImplicit;
/// <summary>
/// Gets the style of the mapping.
/// </summary>
public MappingStyle Style { get; }
/// <summary>
/// Initializes a new instance of the <see cref="MappingStart"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
/// <param name="style">The style of the mapping.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style, Mark start, Mark end)
: base(anchor, tag, start, end)
{
this.IsImplicit = isImplicit;
this.Style = style;
}
/// <summary>
/// Initializes a new instance of the <see cref="MappingStart"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="isImplicit">Indicates whether the event is implicit.</param>
/// <param name="style">The style of the mapping.</param>
public MappingStart(AnchorName anchor, TagName tag, bool isImplicit, MappingStyle style)
: this(anchor, tag, isImplicit, style, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MappingStart"/> class.
/// </summary>
public MappingStart()
: this(AnchorName.Empty, TagName.Empty, true, MappingStyle.Any, 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 $"Mapping start [anchor = {Anchor}, tag = {Tag}, isImplicit = {IsImplicit}, style = {Style}]";
}
/// <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: 79e25e33bd9642a4ca1c8c5280b30984
timeCreated: 1427145264
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
// 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>
/// Specifies the style of a mapping.
/// </summary>
public enum MappingStyle
{
/// <summary>
/// Let the emitter choose the style.
/// </summary>
Any,
/// <summary>
/// The block mapping style.
/// </summary>
Block,
/// <summary>
/// The flow mapping style.
/// </summary>
Flow
}
}

View File

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

View File

@@ -0,0 +1,72 @@
// 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>
/// Contains the behavior that is common between node events.
/// </summary>
public abstract class NodeEvent : ParsingEvent
{
/// <summary>
/// Gets the anchor.
/// </summary>
/// <value></value>
public AnchorName Anchor { get; }
/// <summary>
/// Gets the tag.
/// </summary>
/// <value></value>
public TagName Tag { get; }
/// <summary>
/// Gets a value indicating whether this instance is canonical.
/// </summary>
/// <value></value>
public abstract bool IsCanonical
{
get;
}
/// <summary>
/// Initializes a new instance of the <see cref="NodeEvent"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
protected NodeEvent(AnchorName anchor, TagName tag, Mark start, Mark end)
: base(start, end)
{
this.Anchor = anchor;
this.Tag = tag;
}
/// <summary>
/// Initializes a new instance of the <see cref="NodeEvent"/> class.
/// </summary>
protected NodeEvent(AnchorName anchor, TagName tag)
: this(anchor, tag, Mark.Empty, Mark.Empty)
{
}
}
}

View File

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

View File

@@ -0,0 +1,68 @@
// 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>
/// Base class for parsing events.
/// </summary>
public abstract class 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 virtual int NestingIncrease => 0;
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal abstract EventType Type { get; }
/// <summary>
/// Gets the position in the input stream where the event starts.
/// </summary>
public Mark Start { get; }
/// <summary>
/// Gets the position in the input stream where the event ends.
/// </summary>
public Mark End { get; }
/// <summary>
/// Accepts the specified visitor.
/// </summary>
/// <param name="visitor">Visitor to accept, may not be null</param>
public abstract void Accept(IParsingEventVisitor visitor);
/// <summary>
/// Initializes a new instance of the <see cref="ParsingEvent"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
internal ParsingEvent(Mark start, Mark end)
{
this.Start = start ?? throw new System.ArgumentNullException(nameof(start));
this.End = end ?? throw new System.ArgumentNullException(nameof(end));
}
}
}

View File

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

View File

@@ -0,0 +1,143 @@
// 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 scalar event.
/// </summary>
public sealed class Scalar : NodeEvent
{
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type => EventType.Scalar;
/// <summary>
/// Gets the value.
/// </summary>
/// <value>The value.</value>
public string Value { get; }
/// <summary>
/// Gets the style of the scalar.
/// </summary>
/// <value>The style.</value>
public ScalarStyle Style { get; }
/// <summary>
/// Gets a value indicating whether the tag is optional for the plain style.
/// </summary>
public bool IsPlainImplicit { get; }
/// <summary>
/// Gets a value indicating whether the tag is optional for any non-plain style.
/// </summary>
public bool IsQuotedImplicit { get; }
/// <summary>
/// Gets a value indicating whether this instance is canonical.
/// </summary>
/// <value></value>
public override bool IsCanonical => !IsPlainImplicit && !IsQuotedImplicit;
/// <summary>
/// Initializes a new instance of the <see cref="Scalar"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="value">The value.</param>
/// <param name="style">The style.</param>
/// <param name="isPlainImplicit">.</param>
/// <param name="isQuotedImplicit">.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public Scalar(AnchorName anchor, TagName tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit, Mark start, Mark end)
: base(anchor, tag, start, end)
{
this.Value = value;
this.Style = style;
this.IsPlainImplicit = isPlainImplicit;
this.IsQuotedImplicit = isQuotedImplicit;
}
/// <summary>
/// Initializes a new instance of the <see cref="Scalar"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="value">The value.</param>
/// <param name="style">The style.</param>
/// <param name="isPlainImplicit">.</param>
/// <param name="isQuotedImplicit">.</param>
public Scalar(AnchorName anchor, TagName tag, string value, ScalarStyle style, bool isPlainImplicit, bool isQuotedImplicit)
: this(anchor, tag, value, style, isPlainImplicit, isQuotedImplicit, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scalar"/> class.
/// </summary>
/// <param name="value">The value.</param>
public Scalar(string value)
: this(AnchorName.Empty, TagName.Empty, value, ScalarStyle.Any, true, true, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scalar"/> class.
/// </summary>
/// <param name="tag">The tag.</param>
/// <param name="value">The value.</param>
public Scalar(TagName tag, string value)
: this(AnchorName.Empty, tag, value, ScalarStyle.Any, true, true, Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="Scalar"/> class.
/// </summary>
public Scalar(AnchorName anchor, TagName tag, string value)
: this(anchor, tag, value, ScalarStyle.Any, true, 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 $"Scalar [anchor = {Anchor}, tag = {Tag}, value = {Value}, style = {Style}, isPlainImplicit = {IsPlainImplicit}, isQuotedImplicit = {IsQuotedImplicit}]";
}
/// <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: 7c9ef7a4a2cc85b40aea8fda0d00cb33
timeCreated: 1427145265
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,79 @@
// 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 sequence end event.
/// </summary>
public sealed class SequenceEnd : 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.SequenceEnd;
/// <summary>
/// Initializes a new instance of the <see cref="SequenceEnd"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public SequenceEnd(Mark start, Mark end)
: base(start, end)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SequenceEnd"/> class.
/// </summary>
public SequenceEnd()
: this(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 "Sequence end";
}
/// <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: 37a7a63228a311b46ae903ea604105df
timeCreated: 1427145263
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,105 @@
// 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 sequence start event.
/// </summary>
public sealed class SequenceStart : NodeEvent
{
/// <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.SequenceStart;
/// <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>
/// Gets a value indicating whether this instance is canonical.
/// </summary>
/// <value></value>
public override bool IsCanonical => !IsImplicit;
/// <summary>
/// Gets the style.
/// </summary>
/// <value>The style.</value>
public SequenceStyle Style { get; }
/// <summary>
/// Initializes a new instance of the <see cref="SequenceStart"/> class.
/// </summary>
/// <param name="anchor">The anchor.</param>
/// <param name="tag">The tag.</param>
/// <param name="isImplicit">if set to <c>true</c> [is implicit].</param>
/// <param name="style">The style.</param>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public SequenceStart(AnchorName anchor, TagName tag, bool isImplicit, SequenceStyle style, Mark start, Mark end)
: base(anchor, tag, start, end)
{
this.IsImplicit = isImplicit;
this.Style = style;
}
/// <summary>
/// Initializes a new instance of the <see cref="SequenceStart"/> class.
/// </summary>
public SequenceStart(AnchorName anchor, TagName tag, bool isImplicit, SequenceStyle style)
: this(anchor, tag, isImplicit, style, 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 $"Sequence start [anchor = {Anchor}, tag = {Tag}, isImplicit = {IsImplicit}, style = {Style}]";
}
/// <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: d0414698332e0c643ad3fddd1b907b5e
timeCreated: 1427145266
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,44 @@
// 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>
/// Specifies the style of a sequence.
/// </summary>
public enum SequenceStyle
{
/// <summary>
/// Let the emitter choose the style.
/// </summary>
Any,
/// <summary>
/// The block sequence style.
/// </summary>
Block,
/// <summary>
/// The flow sequence style.
/// </summary>
Flow
}
}

View File

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

View File

@@ -0,0 +1,91 @@
// 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 stream end event.
/// </summary>
public sealed class StreamEnd : 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
{
get
{
return -1;
}
}
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type
{
get
{
return EventType.StreamEnd;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="StreamEnd"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public StreamEnd(Mark start, Mark end)
: base(start, end)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="StreamEnd"/> class.
/// </summary>
public StreamEnd()
: this(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 "Stream end";
}
/// <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: 703673d959fca474691646e24e9ccedb
timeCreated: 1427145264
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,91 @@
// 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 stream start event.
/// </summary>
public sealed class StreamStart : 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
{
get
{
return 1;
}
}
/// <summary>
/// Gets the event type, which allows for simpler type comparisons.
/// </summary>
internal override EventType Type
{
get
{
return EventType.StreamStart;
}
}
/// <summary>
/// Initializes a new instance of the <see cref="StreamStart"/> class.
/// </summary>
public StreamStart()
: this(Mark.Empty, Mark.Empty)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="StreamStart"/> class.
/// </summary>
/// <param name="start">The start position of the event.</param>
/// <param name="end">The end position of the event.</param>
public StreamStart(Mark start, Mark end)
: base(start, end)
{
}
/// <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 "Stream start";
}
/// <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: 8127a5c9cbbe94547a9c1d39fee327db
timeCreated: 1427145265
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.
using System;
namespace YamlDotNet.Core
{
/// <summary>
/// The exception that is thrown when an alias references an anchor
/// that has not yet been defined in a context that does not support forward references.
/// </summary>
public sealed class ForwardAnchorNotSupportedException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public ForwardAnchorNotSupportedException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AnchorNotFoundException"/> class.
/// </summary>
public ForwardAnchorNotSupportedException(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 ForwardAnchorNotSupportedException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

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

View File

@@ -0,0 +1,60 @@
// 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
{
/// <summary>
/// Supports implementations of <see cref="object.GetHashCode"/> by providing methods to combine two hash codes.
/// </summary>
internal static class HashCode
{
/// <summary>
/// Combines two hash codes.
/// </summary>
/// <param name="h1">The first hash code.</param>
/// <param name="h2">The second hash code.</param>
/// <returns></returns>
public static int CombineHashCodes(int h1, int h2)
{
return ((h1 << 5) + h1) ^ h2;
}
public static int CombineHashCodes(int h1, object? o2)
{
return CombineHashCodes(h1, GetHashCode(o2));
}
public static int CombineHashCodes(object? first, params object?[] others)
{
var hashCode = GetHashCode(first);
foreach (var other in others)
{
hashCode = CombineHashCodes(hashCode, other);
}
return hashCode;
}
private static int GetHashCode(object? obj)
{
return obj != null ? obj.GetHashCode() : 0;
}
}
}

View File

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

View File

@@ -0,0 +1,36 @@
// 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.Events;
namespace YamlDotNet.Core
{
/// <summary>
/// Represents a YAML stream emitter.
/// </summary>
public interface IEmitter
{
/// <summary>
/// Emits an event.
/// </summary>
void Emit(ParsingEvent @event);
}
}

View File

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

View File

@@ -0,0 +1,42 @@
// 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 interface ILookAheadBuffer
{
/// <summary>
/// Gets a value indicating whether the end of the input reader has been reached.
/// </summary>
bool EndOfInput { get; }
/// <summary>
/// Gets the character at the specified offset.
/// </summary>
char Peek(int offset);
/// <summary>
/// Skips the next <paramref name="length"/> characters. Those characters must have been
/// obtained first by calling the <see cref="Peek"/> method.
/// </summary>
void Skip(int length);
}
}

View File

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

View File

@@ -0,0 +1,43 @@
// 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.Events;
namespace YamlDotNet.Core
{
/// <summary>
/// Represents a YAML stream parser.
/// </summary>
public interface IParser
{
/// <summary>
/// Gets the current event. Returns null before the first call to <see cref="MoveNext" />,
/// and also after <see cref="MoveNext" /> returns false.
/// </summary>
ParsingEvent? Current { get; }
/// <summary>
/// Moves to the next event.
/// </summary>
/// <returns>Returns true if there are more events available, otherwise returns false.</returns>
bool MoveNext();
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: fc2416e849d87aa4598d335c421f7117
timeCreated: 1427145267
licenseType: Store
MonoImporter:
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 YamlDotNet.Core.Tokens;
namespace YamlDotNet.Core
{
/// <summary>
/// Defines the interface for a stand-alone YAML scanner that
/// converts a sequence of characters into a sequence of YAML tokens.
/// </summary>
public interface IScanner
{
/// <summary>
/// Gets the current position inside the input stream.
/// </summary>
/// <value>The current position.</value>
Mark CurrentPosition { get; }
/// <summary>
/// Gets the current token.
/// </summary>
Token? Current { get; }
/// <summary>
/// Moves to the next token and consumes the current token.
/// </summary>
bool MoveNext();
/// <summary>
/// Moves to the next token without consuming the current token.
/// </summary>
bool MoveNextWithoutConsuming();
/// <summary>
/// Consumes the current token.
/// </summary>
void ConsumeCurrent();
}
}

View File

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

View File

@@ -0,0 +1,216 @@
// 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.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using YamlDotNet.Helpers;
namespace YamlDotNet.Core
{
/// <summary>
/// Generic queue on which items may be inserted
/// </summary>
public sealed class InsertionQueue<T> : IEnumerable<T>
{
private const int DefaultInitialCapacity = 1 << 7; // Must be a power of 2
// Circular buffer
private T[] items;
private int readPtr;
private int writePtr;
private int mask;
private int count = 0;
public InsertionQueue(int initialCapacity = DefaultInitialCapacity)
{
if (initialCapacity <= 0)
{
throw new ArgumentOutOfRangeException(nameof(initialCapacity), "The initial capacity must be a positive number.");
}
if (!initialCapacity.IsPowerOfTwo())
{
throw new ArgumentException("The initial capacity must be a power of 2.", nameof(initialCapacity));
}
items = new T[initialCapacity];
readPtr = initialCapacity / 2;
writePtr = initialCapacity / 2;
mask = initialCapacity - 1;
}
/// <summary>
/// Gets the number of items that are contained by the queue.
/// </summary>
public int Count => count;
public int Capacity => items.Length;
/// <summary>
/// Enqueues the specified item.
/// </summary>
/// <param name="item">The item to be enqueued.</param>
public void Enqueue(T item)
{
ResizeIfNeeded();
items[writePtr] = item;
writePtr = (writePtr - 1) & mask;
++count;
}
/// <summary>
/// Dequeues an item.
/// </summary>
/// <returns>Returns the item that been dequeued.</returns>
public T Dequeue()
{
if (count == 0)
{
throw new InvalidOperationException("The queue is empty");
}
var item = items[readPtr];
readPtr = (readPtr - 1) & mask;
--count;
return item;
}
/// <summary>
/// Inserts an item at the specified index.
/// </summary>
/// <param name="index">The index where to insert the item.</param>
/// <param name="item">The item to be inserted.</param>
public void Insert(int index, T item)
{
if (index > count)
{
throw new InvalidOperationException("Cannot insert outside of the bounds of the queue");
}
ResizeIfNeeded();
CalculateInsertionParameters(
mask, count, index,
ref readPtr, ref writePtr,
out var insertPtr,
out var copyIndex, out var copyOffset, out var copyLength
);
if (copyLength != 0)
{
Array.Copy(items, copyIndex, items, copyIndex + copyOffset, copyLength);
}
items[insertPtr] = item;
++count;
}
private void ResizeIfNeeded()
{
var capacity = items.Length;
if (count == capacity)
{
Debug.Assert(readPtr == writePtr);
var newItems = new T[capacity * 2];
var beginCount = readPtr + 1;
if (beginCount > 0)
{
Array.Copy(items, 0, newItems, 0, beginCount);
}
writePtr += capacity;
var endCount = capacity - beginCount;
if (endCount > 0)
{
Array.Copy(items, readPtr + 1, newItems, writePtr + 1, endCount);
}
items = newItems;
mask = mask * 2 + 1;
}
}
internal static void CalculateInsertionParameters(int mask, int count, int index, ref int readPtr, ref int writePtr, out int insertPtr, out int copyIndex, out int copyOffset, out int copyLength)
{
var indexOfLastElement = (readPtr + 1) & mask;
if (index == 0)
{
insertPtr = readPtr = indexOfLastElement;
// No copy is needed
copyIndex = 0;
copyOffset = 0;
copyLength = 0;
return;
}
insertPtr = (readPtr - index) & mask;
if (index == count)
{
writePtr = (writePtr - 1) & mask;
// No copy is needed
copyIndex = 0;
copyOffset = 0;
copyLength = 0;
return;
}
var canMoveRight = indexOfLastElement >= insertPtr;
var moveRightCost = canMoveRight ? readPtr - insertPtr : int.MaxValue;
var canMoveLeft = writePtr <= insertPtr;
var moveLeftCost = canMoveLeft ? insertPtr - writePtr : int.MaxValue;
if (moveRightCost <= moveLeftCost)
{
++insertPtr;
++readPtr;
copyIndex = insertPtr;
copyOffset = 1;
copyLength = moveRightCost;
}
else
{
copyIndex = writePtr + 1;
copyOffset = -1;
copyLength = moveLeftCost;
writePtr = (writePtr - 1) & mask;
}
}
public IEnumerator<T> GetEnumerator()
{
var ptr = readPtr;
for (var i = 0; i < Count; i++)
{
yield return items[ptr];
ptr = (ptr - 1) & mask;
}
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
}

View File

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

View File

@@ -0,0 +1,170 @@
// 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;
using System.IO;
using YamlDotNet.Helpers;
namespace YamlDotNet.Core
{
/// <summary>
/// Provides access to a stream and allows to peek at the next characters,
/// up to the buffer's capacity.
/// </summary>
/// <remarks>
/// This class implements a circular buffer with a fixed capacity.
/// </remarks>
public sealed class LookAheadBuffer : ILookAheadBuffer
{
private readonly TextReader input;
private readonly char[] buffer;
private readonly int blockSize;
private readonly int mask;
private int firstIndex;
private int writeOffset;
private int count;
private bool endOfInput;
/// <summary>
/// Initializes a new instance of the <see cref="LookAheadBuffer"/> class.
/// </summary>
/// <param name="input">The input.</param>
/// <param name="capacity">The capacity.</param>
public LookAheadBuffer(TextReader input, int capacity)
{
if (capacity < 1)
{
throw new ArgumentOutOfRangeException(nameof(capacity), "The capacity must be positive.");
}
if (!capacity.IsPowerOfTwo())
{
throw new ArgumentException("The capacity must be a power of 2.", nameof(capacity));
}
this.input = input ?? throw new ArgumentNullException(nameof(input));
blockSize = capacity;
// Allocate twice the required capacity to ensure that
buffer = new char[capacity * 2];
mask = capacity * 2 - 1;
}
/// <summary>
/// Gets a value indicating whether the end of the input reader has been reached.
/// </summary>
public bool EndOfInput => endOfInput && count == 0;
/// <summary>
/// Gets the index of the character for the specified offset.
/// </summary>
private int GetIndexForOffset(int offset)
{
return (firstIndex + offset) & mask;
}
/// <summary>
/// Gets the character at the specified offset.
/// </summary>
public char Peek(int offset)
{
#if DEBUG
if (offset < 0 || offset >= blockSize)
{
throw new ArgumentOutOfRangeException(nameof(offset), "The offset must be between zero and the capacity of the buffer.");
}
#endif
if (offset >= count)
{
FillBuffer();
}
if (offset < count)
{
return buffer[(firstIndex + offset) & mask];
}
else
{
return '\0';
}
}
/// <summary>
/// Reads characters until at least <paramref name="length"/> characters are in the buffer.
/// </summary>
/// <param name="length">
/// Number of characters to cache.
/// </param>
public void Cache(int length)
{
if (length >= count)
{
FillBuffer();
}
}
private void FillBuffer()
{
if (endOfInput)
{
return;
}
var remainingSize = blockSize;
do
{
var readCount = input.Read(buffer, writeOffset, remainingSize);
if (readCount == 0)
{
endOfInput = true;
return;
}
remainingSize -= readCount;
writeOffset += readCount;
count += readCount;
} while (remainingSize > 0);
if (writeOffset == buffer.Length)
{
writeOffset = 0;
}
Debug.Assert(writeOffset == 0 || writeOffset == blockSize);
}
/// <summary>
/// Skips the next <paramref name="length"/> characters. Those characters must have been
/// obtained first by calling the <see cref="Peek"/> or <see cref="Cache"/> methods.
/// </summary>
public void Skip(int length)
{
if (length < 1 || length > blockSize)
{
throw new ArgumentOutOfRangeException(nameof(length), "The length must be between 1 and the number of characters in the buffer. Use the Peek() and / or Cache() methods to fill the buffer.");
}
firstIndex = GetIndexForOffset(length);
count -= length;
}
}
}

View File

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

View File

@@ -0,0 +1,141 @@
// 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>
/// Represents a location inside a file
/// </summary>
public sealed class Mark : IEquatable<Mark>, IComparable<Mark>, IComparable
{
/// <summary>
/// Gets a <see cref="Mark"/> with empty values.
/// </summary>
public static readonly Mark Empty = new Mark();
/// <summary>
/// Gets / sets the absolute offset in the file
/// </summary>
public int Index { get; }
/// <summary>
/// Gets / sets the number of the line
/// </summary>
public int Line { get; }
/// <summary>
/// Gets / sets the index of the column
/// </summary>
public int Column { get; }
public Mark()
{
Line = 1;
Column = 1;
}
public Mark(int index, int line, int column)
{
if (index < 0)
{
throw new ArgumentOutOfRangeException(nameof(index), "Index must be greater than or equal to zero.");
}
if (line < 1)
{
throw new ArgumentOutOfRangeException(nameof(line), "Line must be greater than or equal to 1.");
}
if (column < 1)
{
throw new ArgumentOutOfRangeException(nameof(column), "Column must be greater than or equal to 1.");
}
Index = index;
Line = line;
Column = column;
}
/// <summary>
/// Returns a <see cref="string"/> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string"/> that represents this instance.
/// </returns>
public override string ToString()
{
return $"Line: {Line}, Col: {Column}, Idx: {Index}";
}
/// <summary />
public override bool Equals(object? obj)
{
return Equals(obj as Mark);
}
/// <summary />
public bool Equals(Mark? other)
{
return other != null
&& Index == other.Index
&& Line == other.Line
&& Column == other.Column;
}
/// <summary />
public override int GetHashCode()
{
return HashCode.CombineHashCodes(
Index.GetHashCode(),
HashCode.CombineHashCodes(
Line.GetHashCode(),
Column.GetHashCode()
)
);
}
/// <summary />
public int CompareTo(object? obj)
{
if (obj == null)
{
throw new ArgumentNullException(nameof(obj));
}
return CompareTo(obj as Mark);
}
/// <summary />
public int CompareTo(Mark? other)
{
if (other == null)
{
throw new ArgumentNullException(nameof(other));
}
var cmp = Line.CompareTo(other.Line);
if (cmp == 0)
{
cmp = Column.CompareTo(other.Column);
}
return cmp;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 9a02d917bb4d2164ea20caaafce2bb0b
timeCreated: 1427145265
licenseType: Store
MonoImporter:
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>
/// Exception that is thrown when an infinite recursion is detected.
/// </summary>
public sealed class MaximumRecursionLevelReachedException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="MaximumRecursionLevelReachedException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public MaximumRecursionLevelReachedException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MaximumRecursionLevelReachedException"/> class.
/// </summary>
public MaximumRecursionLevelReachedException(Mark start, Mark end, string message)
: base(start, end, message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="MaximumRecursionLevelReachedException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="inner">The inner.</param>
public MaximumRecursionLevelReachedException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

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

View File

@@ -0,0 +1,311 @@
// 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.Collections;
using System.Collections.Generic;
using System.Linq;
using YamlDotNet.Core.Events;
namespace YamlDotNet.Core
{
/// <summary>
/// Simple implementation of <see cref="IParser"/> that implements merging: http://yaml.org/type/merge.html
/// </summary>
public sealed class MergingParser : IParser
{
private readonly ParsingEventCollection events;
private readonly IParser innerParser;
private IEnumerator<LinkedListNode<ParsingEvent>> iterator;
private bool merged;
public MergingParser(IParser innerParser)
{
events = new ParsingEventCollection();
merged = false;
iterator = events.GetEnumerator();
this.innerParser = innerParser;
}
public ParsingEvent? Current => iterator.Current?.Value;
public bool MoveNext()
{
if (!merged)
{
Merge();
events.CleanMarked();
iterator = events.GetEnumerator();
merged = true;
}
return iterator.MoveNext();
}
private void Merge()
{
while (innerParser.MoveNext())
{
events.Add(innerParser.Current!);
}
foreach (var node in events)
{
if (IsMergeToken(node))
{
events.MarkDeleted(node);
if (!HandleMerge(node.Next))
{
throw new SemanticErrorException(node.Value.Start, node.Value.End, "Unrecognized merge key pattern");
}
}
}
}
private bool HandleMerge(LinkedListNode<ParsingEvent>? node)
{
if (node == null)
{
return false;
}
if (node.Value is AnchorAlias anchorAlias)
{
return HandleAnchorAlias(node, node, anchorAlias);
}
if (node.Value is SequenceStart)
{
return HandleSequence(node);
}
return false;
}
private bool HandleMergeSequence(LinkedListNode<ParsingEvent> sequenceStart, LinkedListNode<ParsingEvent>? node)
{
if (node is null)
{
return false;
}
if (node.Value is AnchorAlias anchorAlias)
{
return HandleAnchorAlias(sequenceStart, node, anchorAlias);
}
if (node.Value is SequenceStart)
{
return HandleSequence(node);
}
return false;
}
private bool IsMergeToken(LinkedListNode<ParsingEvent> node)
{
return node.Value is Scalar merge && merge.Value == "<<";
}
private bool HandleAnchorAlias(LinkedListNode<ParsingEvent> node, LinkedListNode<ParsingEvent> anchorNode, AnchorAlias anchorAlias)
{
var mergedEvents = GetMappingEvents(anchorAlias.Value);
events.AddAfter(node, mergedEvents);
events.MarkDeleted(anchorNode);
return true;
}
private bool HandleSequence(LinkedListNode<ParsingEvent> node)
{
var sequenceStart = node;
events.MarkDeleted(node);
var current = node;
while (current != null)
{
if (current.Value is SequenceEnd)
{
events.MarkDeleted(current);
return true;
}
var next = current.Next;
HandleMergeSequence(sequenceStart, next);
current = next;
}
return true;
}
private IEnumerable<ParsingEvent> GetMappingEvents(AnchorName anchor)
{
var cloner = new ParsingEventCloner();
var nesting = 0;
return events.FromAnchor(anchor)
.Select(e => e.Value)
.TakeWhile(e => (nesting += e.NestingIncrease) >= 0)
.Select(e => cloner.Clone(e));
}
private sealed class ParsingEventCollection : IEnumerable<LinkedListNode<ParsingEvent>>
{
private readonly LinkedList<ParsingEvent> events;
private readonly HashSet<LinkedListNode<ParsingEvent>> deleted;
private readonly Dictionary<AnchorName, LinkedListNode<ParsingEvent>> references;
public ParsingEventCollection()
{
events = new LinkedList<ParsingEvent>();
deleted = new HashSet<LinkedListNode<ParsingEvent>>();
references = new Dictionary<AnchorName, LinkedListNode<ParsingEvent>>();
}
public void AddAfter(LinkedListNode<ParsingEvent> node, IEnumerable<ParsingEvent> items)
{
foreach (var item in items)
{
node = events.AddAfter(node, item);
}
}
public void Add(ParsingEvent item)
{
var node = events.AddLast(item);
AddReference(item, node);
}
public void MarkDeleted(LinkedListNode<ParsingEvent> node)
{
deleted.Add(node);
}
public void CleanMarked()
{
foreach (var node in deleted)
{
events.Remove(node);
}
}
public IEnumerable<LinkedListNode<ParsingEvent>> FromAnchor(AnchorName anchor)
{
var node = references[anchor].Next;
return Enumerate(node);
}
public IEnumerator<LinkedListNode<ParsingEvent>> GetEnumerator() => Enumerate(events.First).GetEnumerator();
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
private IEnumerable<LinkedListNode<ParsingEvent>> Enumerate(LinkedListNode<ParsingEvent>? node)
{
while (node != null)
{
yield return node;
node = node.Next;
}
}
private void AddReference(ParsingEvent item, LinkedListNode<ParsingEvent> node)
{
if (item is MappingStart mappingStart)
{
var anchor = mappingStart.Anchor;
if (!anchor.IsEmpty)
{
references[anchor] = node;
}
}
}
}
private sealed class ParsingEventCloner : IParsingEventVisitor
{
private ParsingEvent? clonedEvent;
public ParsingEvent Clone(ParsingEvent e)
{
e.Accept(this);
if (clonedEvent == null)
{
throw new InvalidOperationException($"Could not clone event of type '{e.Type}'");
}
return clonedEvent;
}
void IParsingEventVisitor.Visit(AnchorAlias e)
{
clonedEvent = new AnchorAlias(e.Value, e.Start, e.End);
}
void IParsingEventVisitor.Visit(StreamStart e)
{
throw new NotSupportedException();
}
void IParsingEventVisitor.Visit(StreamEnd e)
{
throw new NotSupportedException();
}
void IParsingEventVisitor.Visit(DocumentStart e)
{
throw new NotSupportedException();
}
void IParsingEventVisitor.Visit(DocumentEnd e)
{
throw new NotSupportedException();
}
void IParsingEventVisitor.Visit(Scalar e)
{
clonedEvent = new Scalar(AnchorName.Empty, e.Tag, e.Value, e.Style, e.IsPlainImplicit, e.IsQuotedImplicit, e.Start, e.End);
}
void IParsingEventVisitor.Visit(SequenceStart e)
{
clonedEvent = new SequenceStart(AnchorName.Empty, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
}
void IParsingEventVisitor.Visit(SequenceEnd e)
{
clonedEvent = new SequenceEnd(e.Start, e.End);
}
void IParsingEventVisitor.Visit(MappingStart e)
{
clonedEvent = new MappingStart(AnchorName.Empty, e.Tag, e.IsImplicit, e.Style, e.Start, e.End);
}
void IParsingEventVisitor.Visit(MappingEnd e)
{
clonedEvent = new MappingEnd(e.Start, e.End);
}
void IParsingEventVisitor.Visit(Comment e)
{
throw new NotSupportedException();
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 2aee5019246749c40a971ff855ffba79
timeCreated: 1427145263
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: 26cca4bc9fdfb2d429b2181c273ab7b7
timeCreated: 1427145263
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,151 @@
// 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.CodeAnalysis;
using System.IO;
using YamlDotNet.Core.Events;
namespace YamlDotNet.Core
{
/// <summary>
/// Extension methods that provide useful abstractions over <see cref="IParser"/>.
/// </summary>
public static class ParserExtensions
{
/// <summary>
/// Ensures that the current event is of the specified type, returns it and moves to the next event.
/// </summary>
/// <typeparam name="T">Type of the <see cref="ParsingEvent"/>.</typeparam>
/// <returns>Returns the current event.</returns>
/// <exception cref="YamlException">If the current event is not of the specified type.</exception>
public static T Consume<T>(this IParser parser) where T : ParsingEvent
{
var required = parser.Require<T>();
parser.MoveNext();
return required;
}
/// <summary>
/// Checks whether the current event is of the specified type.
/// If the event is of the specified type, returns it and moves to the next event.
/// Otherwise returns null.
/// </summary>
/// <typeparam name="T">Type of the <see cref="ParsingEvent"/>.</typeparam>
/// <returns>Returns true if the current event is of type T; otherwise returns null.</returns>
public static bool TryConsume<T>(this IParser parser, [MaybeNullWhen(false)] out T @event) where T : ParsingEvent
{
if (parser.Accept(out @event!))
{
parser.MoveNext();
return true;
}
return false;
}
/// <summary>
/// Enforces that the current event is of the specified type.
/// </summary>
/// <typeparam name="T">Type of the <see cref="ParsingEvent"/>.</typeparam>
/// <returns>Returns the current event.</returns>
/// <exception cref="YamlException">If the current event is not of the specified type.</exception>
public static T Require<T>(this IParser parser) where T : ParsingEvent
{
if (!parser.Accept<T>(out var required))
{
var @event = parser.Current;
if (@event == null)
{
throw new YamlException($"Expected '{typeof(T).Name}', got nothing.");
}
throw new YamlException(@event.Start, @event.End, $"Expected '{typeof(T).Name}', got '{@event.GetType().Name}' (at {@event.Start}).");
}
return required;
}
/// <summary>
/// Checks whether the current event is of the specified type.
/// </summary>
/// <typeparam name="T">Type of the event.</typeparam>
/// <returns>Returns true if the current event is of type <typeparamref name="T"/>. Otherwise returns false.</returns>
public static bool Accept<T>(this IParser parser, [MaybeNullWhen(false)] out T @event) where T : ParsingEvent
{
if (parser.Current == null)
{
if (!parser.MoveNext())
{
throw new EndOfStreamException();
}
}
if (parser.Current is T evt)
{
@event = evt;
return true;
}
else
{
@event = default!;
return false;
}
}
/// <summary>
/// Skips the current event and any nested event.
/// </summary>
public static void SkipThisAndNestedEvents(this IParser parser)
{
var depth = 0;
do
{
var next = parser.Consume<ParsingEvent>();
depth += next.NestingIncrease;
}
while (depth > 0);
}
[Obsolete("Please use Consume<T>() instead")]
public static T Expect<T>(this IParser parser) where T : ParsingEvent
{
return parser.Consume<T>();
}
[Obsolete("Please use TryConsume<T>(out var evt) instead")]
[return: MaybeNull]
public static T Allow<T>(this IParser parser) where T : ParsingEvent
{
return parser.TryConsume<T>(out var @event) ? @event : default;
}
[Obsolete("Please use Accept<T>(out var evt) instead")]
[return: MaybeNull]
public static T Peek<T>(this IParser parser) where T : ParsingEvent
{
return parser.Accept<T>(out var @event) ? @event : default;
}
[Obsolete("Please use TryConsume<T>(out var evt) or Accept<T>(out var evt) instead")]
public static bool Accept<T>(this IParser parser) where T : ParsingEvent
{
return Accept<T>(parser, out var _);
}
}
}

View File

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

View File

@@ -0,0 +1,51 @@
// 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 ParserState
{
StreamStart,
StreamEnd,
ImplicitDocumentStart,
DocumentStart,
DocumentContent,
DocumentEnd,
BlockNode,
BlockNodeOrIndentlessSequence,
FlowNode,
BlockSequenceFirstEntry,
BlockSequenceEntry,
IndentlessSequenceEntry,
BlockMappingFirstKey,
BlockMappingKey,
BlockMappingValue,
FlowSequenceFirstEntry,
FlowSequenceEntry,
FlowSequenceEntryMappingKey,
FlowSequenceEntryMappingValue,
FlowSequenceEntryMappingEnd,
FlowMappingFirstKey,
FlowMappingKey,
FlowMappingValue,
FlowMappingEmptyValue
}
}

View File

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

View File

@@ -0,0 +1,80 @@
// 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>
/// Keeps track of the <see cref="current"/> recursion level,
/// and throws <see cref="MaximumRecursionLevelReachedException"/>
/// whenever <see cref="Maximum"/> is reached.
/// </summary>
internal sealed class RecursionLevel
{
private int current;
public int Maximum { get; }
public RecursionLevel(int maximum)
{
Maximum = maximum;
}
/// <summary>
/// Increments the <see cref="current"/> recursion level,
/// and throws <see cref="MaximumRecursionLevelReachedException"/>
/// if <see cref="Maximum"/> is reached.
/// </summary>
public void Increment()
{
if (!TryIncrement())
{
throw new MaximumRecursionLevelReachedException("Maximum level of recursion reached");
}
}
/// <summary>
/// Increments the <see cref="current"/> recursion level,
/// and returns whether <see cref="current"/> is still less than <see cref="Maximum"/>.
/// </summary>
public bool TryIncrement()
{
if (current < Maximum)
{
++current;
return true;
}
return false;
}
/// <summary>
/// Decrements the <see cref="current"/> recursion level.
/// </summary>
public void Decrement()
{
if (current == 0)
{
throw new InvalidOperationException("Attempted to decrement RecursionLevel to a negative value");
}
--current;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 87346082332b7a2469719bddad64afd5
MonoImporter:
externalObjects: {}
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
{
/// <summary>
/// Specifies the style of a YAML scalar.
/// </summary>
public enum ScalarStyle
{
/// <summary>
/// Let the emitter choose the style.
/// </summary>
Any,
/// <summary>
/// The plain scalar style.
/// </summary>
Plain,
/// <summary>
/// The single-quoted scalar style.
/// </summary>
SingleQuoted,
/// <summary>
/// The double-quoted scalar style.
/// </summary>
DoubleQuoted,
/// <summary>
/// The literal scalar style.
/// </summary>
Literal,
/// <summary>
/// The folded scalar style.
/// </summary>
Folded,
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d8499f656f1f893409f937b46c386cf2
MonoImporter:
externalObjects: {}
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: c0682a65176cd1c42807d5c990f0cc8f
timeCreated: 1427145266
licenseType: Store
MonoImporter:
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>
/// Exception that is thrown when a semantic error is detected on a YAML stream.
/// </summary>
public class SemanticErrorException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="SemanticErrorException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public SemanticErrorException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SemanticErrorException"/> class.
/// </summary>
public SemanticErrorException(Mark start, Mark end, string message)
: base(start, end, message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SemanticErrorException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="inner">The inner.</param>
public SemanticErrorException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

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

View File

@@ -0,0 +1,56 @@
// 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 sealed class SimpleKey
{
private readonly Cursor cursor;
public bool IsPossible { get; private set; }
public void MarkAsImpossible()
{
IsPossible = false;
}
public bool IsRequired { get; }
public int TokenNumber { get; }
public int Index => cursor.Index;
public int Line => cursor.Line;
public int LineOffset => cursor.LineOffset;
public Mark Mark => cursor.Mark();
public SimpleKey()
{
cursor = new Cursor();
}
public SimpleKey(bool isRequired, int tokenNumber, Cursor cursor)
{
IsPossible = true;
IsRequired = isRequired;
TokenNumber = tokenNumber;
this.cursor = new Cursor(cursor);
}
}
}

View File

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

View File

@@ -0,0 +1,61 @@
// 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
{
internal sealed class StringLookAheadBuffer : ILookAheadBuffer
{
private readonly string value;
public int Position { get; private set; }
public StringLookAheadBuffer(string value)
{
this.value = value;
}
public int Length => value.Length;
public bool EndOfInput => IsOutside(Position);
public char Peek(int offset)
{
var index = Position + offset;
return IsOutside(index) ? '\0' : value[index];
}
private bool IsOutside(int index)
{
return index >= value.Length;
}
public void Skip(int length)
{
if (length < 0)
{
throw new ArgumentOutOfRangeException(nameof(length), "The length must be positive.");
}
Position += length;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b821a24261c0caf46b4f2267068dfa19
timeCreated: 1427145266
licenseType: Store
MonoImporter:
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>
/// Exception that is thrown when a syntax error is detected on a YAML stream.
/// </summary>
public sealed class SyntaxErrorException : YamlException
{
/// <summary>
/// Initializes a new instance of the <see cref="SyntaxErrorException"/> class.
/// </summary>
/// <param name="message">The message.</param>
public SyntaxErrorException(string message)
: base(message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SyntaxErrorException"/> class.
/// </summary>
public SyntaxErrorException(Mark start, Mark end, string message)
: base(start, end, message)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="SyntaxErrorException"/> class.
/// </summary>
/// <param name="message">The message.</param>
/// <param name="inner">The inner.</param>
public SyntaxErrorException(string message, Exception inner)
: base(message, inner)
{
}
}
}

View File

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

View File

@@ -0,0 +1,63 @@
// 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.Collections.Generic;
using System.Collections.ObjectModel;
using YamlDotNet.Core.Tokens;
namespace YamlDotNet.Core
{
/// <summary>
/// Collection of <see cref="TagDirective"/>.
/// </summary>
public sealed class TagDirectiveCollection : KeyedCollection<string, TagDirective>
{
/// <summary>
/// Initializes a new instance of the <see cref="TagDirectiveCollection"/> class.
/// </summary>
public TagDirectiveCollection()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="TagDirectiveCollection"/> class.
/// </summary>
/// <param name="tagDirectives">Initial content of the collection.</param>
public TagDirectiveCollection(IEnumerable<TagDirective> tagDirectives)
{
foreach (var tagDirective in tagDirectives)
{
Add(tagDirective);
}
}
/// <summary/>
protected override string GetKeyForItem(TagDirective item) => item.Handle;
/// <summary>
/// Gets a value indicating whether the collection contains a directive with the same handle
/// </summary>
public new bool Contains(TagDirective directive)
{
return Contains(GetKeyForItem(directive));
}
}
}

View File

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

View File

@@ -0,0 +1,91 @@
// 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 struct TagName : IEquatable<TagName>
{
public static readonly TagName Empty = default;
private readonly string? value;
public string Value => value ?? throw new InvalidOperationException("Cannot read the Value of a non-specific tag");
public bool IsEmpty => value is null;
public bool IsNonSpecific => !IsEmpty && (value == "!" || value == "?");
public bool IsLocal => !IsEmpty && Value[0] == '!';
public bool IsGlobal => !IsEmpty && !IsLocal;
public TagName(string value)
{
this.value = value ?? throw new ArgumentNullException(nameof(value));
if (value.Length == 0)
{
throw new ArgumentException("Tag value must not be empty.", nameof(value));
}
if (IsGlobal && !Uri.IsWellFormedUriString(value, UriKind.RelativeOrAbsolute))
{
throw new ArgumentException("Global tags must be valid URIs.", nameof(value));
}
}
public override string ToString() => value ?? "?";
public bool Equals(TagName other) => Equals(value, other.value);
public override bool Equals(object? obj)
{
return obj is TagName other && Equals(other);
}
public override int GetHashCode()
{
return value?.GetHashCode() ?? 0;
}
public static bool operator ==(TagName left, TagName right)
{
return left.Equals(right);
}
public static bool operator !=(TagName left, TagName right)
{
return !(left == right);
}
public static bool operator ==(TagName left, string right)
{
return Equals(left.value, right);
}
public static bool operator !=(TagName left, string right)
{
return !(left == right);
}
public static implicit operator TagName(string? value) => value == null ? Empty : new TagName(value);
}
}

View File

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

View File

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

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