Repository navigation
Expand file tree
/
Copy pathSymbolBase.cs
More file actions
72 lines (62 loc) · 2.31 KB
/
Copy pathSymbolBase.cs
File metadata and controls
72 lines (62 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.Web.Razor.Parser.SyntaxTree;
using System.Web.Razor.Text;
using Microsoft.Internal.Web.Utils;
namespace System.Web.Razor.Tokenizer.Symbols
{
public abstract class SymbolBase<TType> : ISymbol
{
protected SymbolBase(SourceLocation start, string content, TType type, IEnumerable<RazorError> errors)
{
if (content == null)
{
throw new ArgumentNullException("content");
}
if (type == null)
{
throw new ArgumentNullException("type");
}
Start = start;
Content = content;
Type = type;
Errors = errors;
}
public SourceLocation Start { get; private set; }
public string Content { get; private set; }
public IEnumerable<RazorError> Errors { get; private set; }
[SuppressMessage("Microsoft.Naming", "CA1721:PropertyNamesShouldNotMatchGetMethods", Justification = "This is the most appropriate name for this property and conflicts are unlikely")]
public TType Type { get; private set; }
public override bool Equals(object obj)
{
SymbolBase<TType> other = obj as SymbolBase<TType>;
return other != null &&
Start.Equals(other.Start) &&
String.Equals(Content, other.Content, StringComparison.Ordinal) &&
Type.Equals(other.Type);
}
public override int GetHashCode()
{
return HashCodeCombiner.Start()
.Add(Start)
.Add(Content)
.Add(Type)
.CombinedHash;
}
public override string ToString()
{
return String.Format(CultureInfo.InvariantCulture, "{0} {1} - [{2}]", Start, Type, Content);
}
public void OffsetStart(SourceLocation documentStart)
{
Start = documentStart + Start;
}
public void ChangeStart(SourceLocation newStart)
{
Start = newStart;
}
}
}