-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathIniProperty.cs
50 lines (46 loc) · 1.77 KB
/
IniProperty.cs
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
using BytecodeApi.Extensions;
using System.Diagnostics;
namespace BytecodeApi.IniParser;
/// <summary>
/// Represents a property of an <see cref="IniFile" />.
/// </summary>
[DebuggerDisplay($"{nameof(IniProperty)}: Name = {{Name}}, Value = {{Value}}")]
public sealed class IniProperty
{
/// <summary>
/// Gets or sets the name of this INI property.
/// </summary>
public string Name { get; set; }
/// <summary>
/// Gets or sets the value of this INI property.
/// </summary>
public string Value { get; set; }
/// <summary>
/// Gets or sets the parsed <see cref="int" /> value of the <see cref="Value" /> property. If conversion fails, <see langword="null" /> is returned. Assigning a value sets the <see cref="Value" /> property by converting the value to a <see cref="string" />.
/// </summary>
public int? Int32Value
{
get => Value?.ToInt32OrNull();
set => Value = value?.ToString() ?? "";
}
/// <summary>
/// Gets or sets the parsed <see cref="long" /> value of the <see cref="Value" /> property. If conversion fails, <see langword="null" /> is returned. Assigning a value sets the <see cref="Value" /> property by converting the value to a <see cref="string" />.
/// </summary>
public long? Int64Value
{
get => Value?.ToInt64OrNull();
set => Value = value?.ToString() ?? "";
}
/// <summary>
/// Initializes a new instance of the <see cref="IniProperty" /> class with the specified name and value.
/// </summary>
/// <param name="name">A <see cref="string" /> value specifying the name of this INI property.</param>
/// <param name="value">A <see cref="string" /> value specifying the value of this INI property.</param>
public IniProperty(string name, string value)
{
Check.ArgumentNull(name);
Check.ArgumentNull(value);
Name = name;
Value = value;
}
}