Skip to content

Commit fa85a74

Browse files
committed
Move operators to correct file
1 parent 6c26aea commit fa85a74

File tree

3 files changed

+50
-33
lines changed

3 files changed

+50
-33
lines changed

ValveKeyValue/ValveKeyValue/KVObject.cs

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ public KVObject()
6868

6969
/// <summary>
7070
/// Initializes a new instance of the <see cref="KVObject"/> class with a string value.
71+
/// If <paramref name="value"/> is <c>null</c>, creates a null-valued instance.
7172
/// </summary>
7273
public KVObject(string value)
7374
{
@@ -81,56 +82,72 @@ public KVObject(string value)
8182
_ref = value;
8283
}
8384

84-
/// <inheritdoc cref="KVObject(string)"/>
85+
/// <summary>
86+
/// Initializes a new instance of the <see cref="KVObject"/> class with a boolean value.
87+
/// </summary>
8588
public KVObject(bool value)
8689
{
8790
ValueType = KVValueType.Boolean;
8891
_scalar = value ? 1L : 0L;
8992
}
9093

91-
/// <inheritdoc cref="KVObject(string)"/>
94+
/// <summary>
95+
/// Initializes a new instance of the <see cref="KVObject"/> class with an integer value.
96+
/// </summary>
9297
public KVObject(int value)
9398
{
9499
ValueType = KVValueType.Int32;
95100
_scalar = value;
96101
}
97102

98-
/// <inheritdoc cref="KVObject(string)"/>
103+
/// <summary>
104+
/// Initializes a new instance of the <see cref="KVObject"/> class with an unsigned integer value.
105+
/// </summary>
99106
public KVObject(uint value)
100107
{
101108
ValueType = KVValueType.UInt32;
102109
_scalar = value;
103110
}
104111

105-
/// <inheritdoc cref="KVObject(string)"/>
112+
/// <summary>
113+
/// Initializes a new instance of the <see cref="KVObject"/> class with a 64-bit integer value.
114+
/// </summary>
106115
public KVObject(long value)
107116
{
108117
ValueType = KVValueType.Int64;
109118
_scalar = value;
110119
}
111120

112-
/// <inheritdoc cref="KVObject(string)"/>
121+
/// <summary>
122+
/// Initializes a new instance of the <see cref="KVObject"/> class with an unsigned 64-bit integer value.
123+
/// </summary>
113124
public KVObject(ulong value)
114125
{
115126
ValueType = KVValueType.UInt64;
116127
_scalar = unchecked((long)value);
117128
}
118129

119-
/// <inheritdoc cref="KVObject(string)"/>
130+
/// <summary>
131+
/// Initializes a new instance of the <see cref="KVObject"/> class with a float value.
132+
/// </summary>
120133
public KVObject(float value)
121134
{
122135
ValueType = KVValueType.FloatingPoint;
123136
_scalar = BitConverter.SingleToInt32Bits(value);
124137
}
125138

126-
/// <inheritdoc cref="KVObject(string)"/>
139+
/// <summary>
140+
/// Initializes a new instance of the <see cref="KVObject"/> class with a double value.
141+
/// </summary>
127142
public KVObject(double value)
128143
{
129144
ValueType = KVValueType.FloatingPoint64;
130145
_scalar = BitConverter.DoubleToInt64Bits(value);
131146
}
132147

133-
/// <inheritdoc cref="KVObject(string)"/>
148+
/// <summary>
149+
/// Initializes a new instance of the <see cref="KVObject"/> class with a pointer value.
150+
/// </summary>
134151
public KVObject(IntPtr value)
135152
{
136153
ValueType = KVValueType.Pointer;
@@ -193,8 +210,6 @@ public KVObject this[int index]
193210

194211
#endregion
195212

196-
// Operators are in KVObject_operators.cs
197-
198213
#region Navigation
199214

200215
/// <summary>
@@ -358,8 +373,6 @@ public void Clear()
358373

359374
#endregion
360375

361-
// IEnumerable<KeyValuePair<string, KVObject>> is in KVObject_IEnumerable.cs
362-
363376
#region Static factory methods
364377

365378
/// <summary>
@@ -452,22 +465,7 @@ public static KVObject Blob(byte[] data)
452465

453466
#endregion
454467

455-
#region Scalar access
456-
457-
/// <summary>Converts this value to a <see cref="bool"/>.</summary>
458-
public bool ToBoolean() => ToBoolean(null);
459-
460-
/// <summary>Converts this value to an <see cref="int"/>.</summary>
461-
public int ToInt32() => ToInt32(null);
462-
463-
/// <summary>Converts this value to a <see cref="long"/>.</summary>
464-
public long ToInt64() => ToInt64(null);
465-
466-
/// <summary>Converts this value to a <see cref="float"/>.</summary>
467-
public float ToSingle() => ToSingle(null);
468-
469-
/// <summary>Converts this value to a <see cref="double"/>.</summary>
470-
public double ToDouble() => ToDouble(null);
468+
#region Blob access
471469

472470
/// <summary>Gets the binary blob data as a byte array.</summary>
473471
public byte[] AsBlob()
@@ -506,9 +504,6 @@ internal List<KeyValuePair<string, KVObject>> GetCollectionList()
506504

507505
#endregion
508506

509-
/// <inheritdoc/>
510-
public override string ToString() => ToString(CultureInfo.InvariantCulture);
511-
512507
#region Private helpers
513508

514509
private void SetChild(string key, KVObject value)

ValveKeyValue/ValveKeyValue/KVObject_IConvertible.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,28 @@ public partial class KVObject : IConvertible
4242

4343
#endregion
4444

45+
#region Convenience overloads
46+
47+
/// <summary>Converts this value to a <see cref="bool"/>.</summary>
48+
public bool ToBoolean() => ToBoolean(null);
49+
50+
/// <summary>Converts this value to an <see cref="int"/>.</summary>
51+
public int ToInt32() => ToInt32(null);
52+
53+
/// <summary>Converts this value to a <see cref="long"/>.</summary>
54+
public long ToInt64() => ToInt64(null);
55+
56+
/// <summary>Converts this value to a <see cref="float"/>.</summary>
57+
public float ToSingle() => ToSingle(null);
58+
59+
/// <summary>Converts this value to a <see cref="double"/>.</summary>
60+
public double ToDouble() => ToDouble(null);
61+
62+
/// <inheritdoc/>
63+
public override string ToString() => ToString(CultureInfo.InvariantCulture);
64+
65+
#endregion
66+
4567
#region Conversion methods
4668

4769
/// <inheritdoc cref="IConvertible.ToBoolean"/>

ValveKeyValue/ValveKeyValue/KVObject_operators.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public partial class KVObject
3434
/// <summary>Implicit cast from <see cref="ushort"/> to <see cref="KVObject"/>.</summary>
3535
public static implicit operator KVObject(ushort value) => new(KVValueType.UInt16, (long)value);
3636

37-
/// <summary>Implicit cast from <see cref="byte"/> to <see cref="KVObject"/>.</summary>
37+
/// <summary>Implicit cast from <see cref="byte"/> to <see cref="KVObject"/>. The value is widened to <see cref="int"/>.</summary>
3838
public static implicit operator KVObject(byte value) => new((int)value);
3939

40-
/// <summary>Implicit cast from <see cref="sbyte"/> to <see cref="KVObject"/>.</summary>
40+
/// <summary>Implicit cast from <see cref="sbyte"/> to <see cref="KVObject"/>. The value is widened to <see cref="int"/>.</summary>
4141
public static implicit operator KVObject(sbyte value) => new((int)value);
4242

4343
/// <summary>Implicit cast from <see cref="IntPtr"/> to <see cref="KVObject"/>.</summary>

0 commit comments

Comments
 (0)