JsonWritableProxyArray<TValue>
Namespace: SnowBank.Data.Json · struct
Implements: IList<TValue>, ICollection<TValue>, IEnumerable<TValue>, IEnumerable, IJsonProxyNode, IJsonSerializable, IJsonPackable
Wraps a JsonArray into a typed mutable proxy that emulates an array of elements of type TValue
Constructors
JsonWritableProxyArray<TValue>
JsonWritableProxyArray<TValue>(MutableJsonValue value, IJsonConverter<TValue> converter = null, IJsonProxyNode parent = null, JsonPathSegment segment = null, IEqualityComparer<TValue> comparer = null)
Properties
Count
int Count { get; }
Item
TValue Item { get; set; }
TValue Item { get; set; }
Methods
Add
void Add(TValue item)
Aggregate
TAccumulate Aggregate<TAccumulate>(TAccumulate seed, Func<TAccumulate, TValue, TAccumulate> handler)
Applies an accumulator function over the items on this array. The specified seed value is used as the initial accumulator value.
seed— The initial accumulator value.handler— An accumulator function to be invoked on each element.
Returns: The final accumulator value.
TResult Aggregate<TAccumulate, TResult>(TAccumulate seed, Func<TAccumulate, TValue, TAccumulate> handler, Func<TAccumulate, TResult> resultSelector)
Applies an accumulator function over the items on this array. The specified seed value is used as the initial accumulator value.
seed— The initial accumulator value.handler— An accumulator function to be invoked on each element.resultSelector— A function to transform the final accumulator value into the result value.
Returns: The transformed final accumulator value.
Clear
void Clear()
Contains
bool Contains(TValue item)
CopyTo
void CopyTo(TValue[] array, int arrayIndex)
Exists
bool Exists()
Tests if the array is present.
Returns: false if the wrapped JSON value is null or missing; otherwise, true.
Find
TValue Find(Predicate<TValue> match)
Searches for an item that matches the conditions defined by the specified predicate, and returns the first occurrence within the entire array.
match— ThePredicatedelegate that defines the conditions of the element to search for.
Returns: The first element that matches the conditions defined by the specified predicate, if found; otherwise, the default value for type TValue.
FindAll
List<TValue> FindAll(Predicate<TValue> match)
Retrieves all the values that match the conditions defined by the specified predicate.
match— ThePredicatedelegate that defines the conditions of the element to search for.
Returns: A List containing all the values that match the conditions defined by the specified predicate, if found; otherwise, an empty List.
GetEnumerator
IEnumerator<TValue> GetEnumerator()
GetPath
JsonPath GetPath()
Returns the path to this node, from the root
JsonPath GetPath(JsonPathSegment child)
Returns the path to a child of this value, from the root
IndexOf
int IndexOf(TValue item)
Find the index of the first occurrence of the specified value in this array.
item— The item to locate in the array.
Returns: The zero-based index of the first occurrence of item within the entire array, if found; otherwise, -1
int IndexOf(TValue item, int index)
Find the index of the first occurrence of the specified value in this array.
item— The item to locate in the array.index— The zero-based starting index of the search. 0 (zero) is valid in an empty array.
Returns: The zero-based index of the first occurrence of item within the range of elements in the array that extends from index to the last element, if found; otherwise, -1
Insert
void Insert(int index, TValue item)
IsArray
bool IsArray()
Tests if the wrapped value is a valid JSON Array.
Returns: true if the wrapped JSON value is a non-null Array; otherwise, false
This can be used to protect against malformed JSON document that would have a different type (object, string literal, ...).
IsArrayOrMissing
bool IsArrayOrMissing()
Tests if the wrapped value is a valid JSON Array, or is null-or-missing.
Returns: true if the wrapped JSON value either null-or-missing, or an Array; otherwise, false
This can be used to protect against malformed JSON document that would have a different type (object, string literal, ...).
IsNullOrEmpty
bool IsNullOrEmpty()
Tests if the array is null, missing, or empty.
Returns: true if the wrapped JSON value is null, missing or an empty array; otherwise, false.
This can return false if the wrapped value is another type, like an object, string literal, etc...
IsNullOrMissing
bool IsNullOrMissing()
Tests if the array is null or missing.
Returns: true if the wrapped JSON value is null or missing; otherwise, false.
This can return false if the wrapped value is another type, like an object, string literal, etc...
Remove
bool Remove(TValue item)
Removes the first occurence of a specific value from the array.
item— The value to remove from the array.
Returns: true if item is found and removed; otherwise, false.
RemoveAt
void RemoveAt(int index)
ToArray
TValue[] ToArray()
ToJsonValue
JsonValue ToJsonValue()
ToList
List<TValue> ToList()
ToString
string ToString()
Visit
void Visit(Action<TValue> handler)
Visit all the elements of this array.
handler— A function to be invoked on each element.
void Visit(Action<TValue, int> handler)
Visit all the elements of this array.
handler— A function to be invoked on each element.