JsonWritableProxyArray<TValue, TProxy>

Namespace: SnowBank.Data.Json · class

Implements: IList<TProxy>, ICollection<TProxy>, IEnumerable<TProxy>, IEnumerable, IJsonProxyNode, IJsonSerializable, IJsonPackable

Wraps a JsonArray into a typed mutable proxy that emulates an array of elements of type TValue

Constructors

JsonWritableProxyArray<TValue, TProxy>

JsonWritableProxyArray<TValue, TProxy>(MutableJsonValue value)

Properties

Count

int Count { get; }

Item

TProxy Item { get; set; }

TProxy Item { get; set; }

Methods

Add

void Add(TProxy value)

void Add(TValue value)

Clear

void Clear()

CopyTo

void CopyTo(TProxy[] 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.

GetEnumerator

IEnumerator<TProxy> 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

Insert

void Insert(int index, TProxy item)

Inserts an item to the array at the specified index.

  • index — The zero-based index at which item should be inserted.
  • item — The instance to insert into the array.

void Insert(int index, TValue item)

Inserts an item to the array at the specified index.

  • index — The zero-based index at which item should be inserted.
  • item — The instance to insert into the array.

void Insert(Index index, TProxy item)

Inserts an item to the array at the specified index.

  • index — The zero-based index at which item should be inserted.
  • item — The instance to insert into the array.

void Insert(Index index, TValue item)

Inserts an item to the array at the specified index.

  • index — The zero-based index at which item should be inserted.
  • item — The instance to insert into the array.

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...

RemoveAll

int RemoveAll(Predicate<TProxy> match)

Removes all the elements that match the conditions defined by the specified predicate.

  • match — The Predicate delegate that defines the conditions of the elements to remove.

Returns: The number of elements removed from the array.

RemoveAt

void RemoveAt(int index)

void RemoveAt(Index index)

Set

void Set(ReadOnlySpan<TValue> items)

Replaces all the elements of this array

  • items — New elements

void Set(TValue[] items)

Replaces all the elements of this array

  • items — New elements

void Set(List<TValue> items)

Replaces all the elements of this array

  • items — New elements

void Set(IEnumerable<TValue> items)

Replaces all the elements of this array

  • items — New elements

ToArray

TValue[] ToArray()

Returns the deserialized elements as a TValue array.

If the contents are only meant to be enumerated once (via foreach or LINQ), you may want to call ToEnumerable instead

ToEnumerable

Enumerable ToEnumerable()

Returns a sequence that enumerates the deserialized TValue elements in this array

ToJsonValue

JsonValue ToJsonValue()

ToList

List<TValue> ToList()

Returns the deserialized elements as a List

ToString

string ToString()