Struct ConfigFileProperty
Represents a single, immutable, typed property value stored within a ConfigFileGroup. The supported data types are defined by ConfigFilePropertyType: boolean, 32-bit integer, single- and double-precision float, string, nested group, and ordered array.
Instances must be created via the static factory methods (Bool(bool),
Int(int), Float(float), Double(double), String(string),
Group(ConfigFileGroup), Array(List<ConfigFileProperty>)) rather than via default or the
parameterless constructor. A default-constructed instance has IsInitialized
set to false and accessing any typed value accessor will throw
InvalidOperationException.
Because ConfigFileProperty is a value type, it is copied by assignment. This is safe for all primitive types and strings. Group-typed and array-typed properties hold references to the underlying ConfigFileGroup or List<T> - the struct itself is copied, but the referenced heap objects are shared. Use Merge(ConfigFile, ConfigFile) (which deep-clones) if full isolation is required.
Implements
Inherited Members
Namespace: Scylla.Core.Util.File
Assembly: ScyllaCore.dll
Syntax
public readonly struct ConfigFileProperty : IEquatable<ConfigFileProperty>
Properties
ArrayValue
Gets the ordered list of ConfigFileProperty values stored in this
property as a read-only view. The view is backed by the internal list and will reflect
any future modifications made through the ConfigFileGroup API. Always
check Type or use TryGetArray to avoid the thrown exception.
Declaration
public IReadOnlyList<ConfigFileProperty> ArrayValue { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<ConfigFileProperty> |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Array, or if
this instance was not created via a factory method (IsInitialized is |
BoolValue
Gets the boolean value stored in this property. Always check Type or
use the TryGet methods on ConfigFileGroup before accessing this
accessor to avoid the thrown exception.
Declaration
public bool BoolValue { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Bool, or if
this instance was not created via a factory method (IsInitialized is |
DoubleValue
Gets the double-precision floating-point value stored in this property. This is the
type used when a JSON floating-point literal is parsed by FromJSON(string).
Always check Type or use TryGetDouble (which also accepts Float
and Int) to avoid the thrown exception.
Declaration
public double DoubleValue { get; }
Property Value
| Type | Description |
|---|---|
| double |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Double, or if
this instance was not created via a factory method (IsInitialized is |
FloatValue
Gets the single-precision floating-point value stored in this property. Note that JSON
floating-point literals are parsed as Double during
FromJSON(string); a property of type Float can only exist if
it was set programmatically via Float(float) or SetFloat(string, float).
Always check Type or use TryGetFloat (which also accepts Double and
Int) to avoid the thrown exception.
Declaration
public float FloatValue { get; }
Property Value
| Type | Description |
|---|---|
| float |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Float, or if
this instance was not created via a factory method (IsInitialized is |
GroupValue
Gets the ConfigFileGroup reference stored in this property. The returned
reference is not a clone; callers must not assume exclusive ownership. Always check
Type or use TryGetGroup to avoid the thrown exception.
Declaration
public ConfigFileGroup GroupValue { get; }
Property Value
| Type | Description |
|---|---|
| ConfigFileGroup |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Group, or if
this instance was not created via a factory method (IsInitialized is |
IntValue
Gets the 32-bit signed integer value stored in this property. Always check
Type or use the TryGet methods on ConfigFileGroup
before accessing this accessor to avoid the thrown exception.
Declaration
public int IntValue { get; }
Property Value
| Type | Description |
|---|---|
| int |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not Int, or if
this instance was not created via a factory method (IsInitialized is |
IsInitialized
Gets a value indicating whether this instance was created via one of the static factory
methods rather than via default(ConfigFileProperty) or the parameterless constructor.
A value of false means the struct is in an uninitialized state; accessing any
typed accessor on an uninitialized instance will throw InvalidOperationException.
Declaration
public bool IsInitialized { get; }
Property Value
| Type | Description |
|---|---|
| bool |
StringValue
Gets the string value stored in this property. A string property may legitimately hold
a null value, which arises when a JSON null literal is parsed. Use
IsInitialized to distinguish an uninitialized struct (where the accessor
throws) from a valid initialized property whose string value is null. Always
check Type or use TryGetString to avoid the thrown exception.
Declaration
public string StringValue { get; }
Property Value
| Type | Description |
|---|---|
| string |
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | Thrown if Type is not String, or if
this instance was not created via a factory method (IsInitialized is |
Type
Gets the ConfigFilePropertyType that identifies the runtime data type stored in this property. Always check this before accessing a typed accessor to avoid an InvalidOperationException.
Declaration
public ConfigFilePropertyType Type { get; }
Property Value
| Type | Description |
|---|---|
| ConfigFilePropertyType |
Methods
Array(List<ConfigFileProperty>)
Creates a new ConfigFileProperty of type
Array containing an ordered list of values.
A shallow defensive copy of value is made internally; subsequent
modifications to the original list will not affect the stored array. However, elements
that are of type Group share the same underlying
ConfigFileGroup instances by reference. Use
Merge(ConfigFile, ConfigFile) (which performs deep cloning) if full isolation is
required.
Declaration
public static ConfigFileProperty Array(List<ConfigFileProperty> value)
Parameters
| Type | Name | Description |
|---|---|---|
| List<ConfigFileProperty> | value | The ordered list of property values to store. Must not be |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Array. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Bool(bool)
Creates a new ConfigFileProperty of type
Bool holding the specified boolean value.
The resulting property's BoolValue accessor will return
value.
Declaration
public static ConfigFileProperty Bool(bool value)
Parameters
| Type | Name | Description |
|---|---|---|
| bool | value | The boolean value to store ( |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Bool. |
Double(double)
Creates a new ConfigFileProperty of type
Double holding the specified double-precision
float value. This is the type automatically assigned to JSON floating-point literals
during FromJSON(string), and to integer literals that fall outside
the Int32 range.
Declaration
public static ConfigFileProperty Double(double value)
Parameters
| Type | Name | Description |
|---|---|---|
| double | value | The double value to store. NaN and infinity are valid. |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Double. |
Equals(ConfigFileProperty)
Determines whether the specified ConfigFileProperty is equal to this instance by comparing initialization state, Type, and the stored value. For primitive types, equality uses value semantics. For Group and Array types, equality uses reference semantics on the underlying heap object (two independently created groups or arrays with the same content are not considered equal).
Declaration
public bool Equals(ConfigFileProperty other)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigFileProperty | other | The ConfigFileProperty to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Equals(object)
Determines whether the specified object is equal to this
ConfigFileProperty instance. Returns false if obj
is not a ConfigFileProperty. Delegates to
Equals(ConfigFileProperty) for the actual comparison.
Declaration
public override bool Equals(object obj)
Parameters
| Type | Name | Description |
|---|---|---|
| object | obj | The object to compare with this instance. |
Returns
| Type | Description |
|---|---|
| bool |
|
Overrides
Float(float)
Creates a new ConfigFileProperty of type
Float holding the specified single-precision
float value. This type is used when precision at the float level is sufficient.
Note that JSON floating-point literals are parsed as
Double during FromJSON(string);
a Float-typed property can only exist if set programmatically.
Declaration
public static ConfigFileProperty Float(float value)
Parameters
| Type | Name | Description |
|---|---|---|
| float | value | The float value to store. NaN and infinity are valid. |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Float. |
GetHashCode()
Computes a hash code for this ConfigFileProperty based on its Type and the stored value. The hash combines the type ordinal and the value's hash code using a prime multiplier (397) to reduce collision probability. Note that for Group and Array types, the hash is based on reference identity of the underlying heap object.
Declaration
public override int GetHashCode()
Returns
| Type | Description |
|---|---|
| int | A 32-bit signed integer hash code. |
Overrides
Group(ConfigFileGroup)
Creates a new ConfigFileProperty of type Group holding a reference to the specified ConfigFileGroup. The reference is stored directly without defensive copying; callers are responsible for not mutating the group after storing it, or for providing a pre-cloned copy.
Declaration
public static ConfigFileProperty Group(ConfigFileGroup value)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigFileGroup | value | The group to store as the property value. Must not be |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Group. |
Exceptions
| Type | Condition |
|---|---|
| ArgumentNullException | Thrown if |
Int(int)
Creates a new ConfigFileProperty of type
Int holding the specified 32-bit signed integer
value. The resulting property's IntValue accessor will return
value. Note that integer values outside the Int32 range
parsed from JSON are automatically widened to Double
by FromJSON(string).
Declaration
public static ConfigFileProperty Int(int value)
Parameters
| Type | Name | Description |
|---|---|---|
| int | value | The integer value to store. |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type Int. |
String(string)
Creates a new ConfigFileProperty of type
String holding the specified string value.
A null value is permitted and is used to represent a JSON null literal.
Use IsInitialized to distinguish a valid null-string property from an
uninitialized default(ConfigFileProperty).
Declaration
public static ConfigFileProperty String(string value)
Parameters
| Type | Name | Description |
|---|---|---|
| string | value | The string value to store. May be |
Returns
| Type | Description |
|---|---|
| ConfigFileProperty | An initialized ConfigFileProperty of type String. |
ToString()
Returns a human-readable string representation of this property for debugging and
logging purposes. The format is "Type: value" for primitives and strings.
For uninitialized instances the format is "Type: <uninitialized>".
Group-typed properties are shown as "Group: [N properties]" and array-typed
properties as "Array: [N items]" to avoid recursively expanding nested
structures.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string | A diagnostic string describing this property's type and value. |
Overrides
Operators
operator ==(ConfigFileProperty, ConfigFileProperty)
Determines whether two ConfigFileProperty instances are equal using the same semantics as Equals(ConfigFileProperty).
Declaration
public static bool operator ==(ConfigFileProperty left, ConfigFileProperty right)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigFileProperty | left | The left-hand operand. |
| ConfigFileProperty | right | The right-hand operand. |
Returns
| Type | Description |
|---|---|
| bool |
|
operator !=(ConfigFileProperty, ConfigFileProperty)
Determines whether two ConfigFileProperty instances are not equal using the same semantics as Equals(ConfigFileProperty).
Declaration
public static bool operator !=(ConfigFileProperty left, ConfigFileProperty right)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigFileProperty | left | The left-hand operand. |
| ConfigFileProperty | right | The right-hand operand. |
Returns
| Type | Description |
|---|---|
| bool |
|