BGC Tools
Data Structures | Public Member Functions | Data Fields | Properties | Private Member Functions | Private Attributes
LightJson.JsonArray Class Reference

Represents an ordered collection of JsonValues. More...

Inheritance diagram for LightJson.JsonArray:
Inheritance graph
[legend]
Collaboration diagram for LightJson.JsonArray:
Collaboration graph
[legend]

Data Structures

class  JsonArrayDebugView
 

Public Member Functions

 JsonArray ()
 Initializes a new instance of JsonArray. More...
 
 JsonArray (params JsonValue[] values)
 Initializes a new instance and adds the given values to the collection. More...
 
JsonArray Add (JsonValue value)
 Adds the given value to this collection. More...
 
JsonArray AddIfNotNull (JsonValue value)
 Adds the given value to this collection only if the value is not null. More...
 
JsonArray Insert (int index, JsonValue value)
 Inserts the given value at the given index in this collection. More...
 
JsonArray InsertIfNotNull (int index, JsonValue value)
 Inserts the given value at the given index in this collection if it is not null. More...
 
JsonArray Remove (int index)
 Removes the value at the given index. More...
 
JsonArray Clear ()
 Clears the contents of this collection. More...
 
bool Contains (JsonValue item)
 Determines whether the given item is in the JsonArray. More...
 
int IndexOf (JsonValue item)
 Determines the index of the given item in this JsonArray. More...
 
IEnumerator< JsonValueGetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 
override string ToString ()
 Returns a JSON string representing the state of the array. More...
 
string ToString (bool pretty)
 Returns a JSON string representing the state of the array. More...
 

Data Fields

int Count => items.Count
 The number of values in this collection. More...
 

Properties

JsonValue this[int index] [get, set]
 The value at the given index. More...
 

Private Member Functions

System.Collections.IEnumerator System.Collections.IEnumerable. GetEnumerator ()
 Returns an enumerator that iterates through the collection. More...
 

Private Attributes

List< JsonValueitems = new List<JsonValue>()
 

Detailed Description

Represents an ordered collection of JsonValues.

Definition at line 11 of file JsonArray.cs.

Constructor & Destructor Documentation

◆ JsonArray() [1/2]

LightJson.JsonArray.JsonArray ( )
inline

Initializes a new instance of JsonArray.

Definition at line 41 of file JsonArray.cs.

41 { }

◆ JsonArray() [2/2]

LightJson.JsonArray.JsonArray ( params JsonValue []  values)
inline

Initializes a new instance and adds the given values to the collection.

Parameters
valuesThe values to be added to this collection.

Definition at line 47 of file JsonArray.cs.

47  : this()
48  {
49  if (values == null)
50  {
51  throw new ArgumentNullException(nameof(values));
52  }
53 
54  foreach (JsonValue value in values)
55  {
56  items.Add(value);
57  }
58  }
List< JsonValue > items
Definition: JsonArray.cs:13

Member Function Documentation

◆ Add()

JsonArray LightJson.JsonArray.Add ( JsonValue  value)
inline

◆ AddIfNotNull()

JsonArray LightJson.JsonArray.AddIfNotNull ( JsonValue  value)
inline

Adds the given value to this collection only if the value is not null.

Parameters
valueThe value to be added.
Returns
Returns this collection.

Definition at line 76 of file JsonArray.cs.

References LightJson.JsonArray.Add(), and LightJson.JsonValue.IsNull.

77  {
78  if (!value.IsNull)
79  {
80  Add(value);
81  }
82 
83  return this;
84  }
JsonArray Add(JsonValue value)
Adds the given value to this collection.
Definition: JsonArray.cs:65
Here is the call graph for this function:

◆ Clear()

JsonArray LightJson.JsonArray.Clear ( )
inline

Clears the contents of this collection.

Returns
Returns this collection.

Definition at line 129 of file JsonArray.cs.

References LightJson.JsonArray.Clear(), LightJson.JsonArray.Contains(), LightJson.JsonArray.GetEnumerator(), LightJson.JsonArray.IndexOf(), LightJson.Serialization.JsonWriter.Serialize(), and LightJson.JsonArray.ToString().

Referenced by LightJson.JsonArray.Clear().

130  {
131  items.Clear();
132  return this;
133  }
List< JsonValue > items
Definition: JsonArray.cs:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Contains()

bool LightJson.JsonArray.Contains ( JsonValue  item)

Determines whether the given item is in the JsonArray.

Parameters
itemThe item to locate in the JsonArray.
Returns
Returns true if the item is found; otherwise, false.

Referenced by LightJson.JsonArray.Clear().

Here is the caller graph for this function:

◆ GetEnumerator() [1/2]

IEnumerator<JsonValue> LightJson.JsonArray.GetEnumerator ( )

Returns an enumerator that iterates through the collection.

Referenced by LightJson.JsonArray.Clear(), and LightJson.Serialization.JsonWriter.Render().

Here is the caller graph for this function:

◆ GetEnumerator() [2/2]

System.Collections.IEnumerator System.Collections.IEnumerable. LightJson.JsonArray.GetEnumerator ( )
private

Returns an enumerator that iterates through the collection.

◆ IndexOf()

int LightJson.JsonArray.IndexOf ( JsonValue  item)

Determines the index of the given item in this JsonArray.

Parameters
itemThe item to locate in this JsonArray.
Returns
The index of the item, if found. Otherwise, returns -1.

Referenced by LightJson.JsonArray.Clear().

Here is the caller graph for this function:

◆ Insert()

JsonArray LightJson.JsonArray.Insert ( int  index,
JsonValue  value 
)
inline

Inserts the given value at the given index in this collection.

Parameters
indexThe index where the given value will be inserted.
valueThe value to be inserted into this collection.
Returns
Returns this collection.

Definition at line 92 of file JsonArray.cs.

References LightJson.JsonArray.Insert().

Referenced by LightJson.JsonArray.Insert(), and LightJson.JsonArray.InsertIfNotNull().

93  {
94  items.Insert(index, value);
95  return this;
96  }
List< JsonValue > items
Definition: JsonArray.cs:13
Here is the call graph for this function:
Here is the caller graph for this function:

◆ InsertIfNotNull()

JsonArray LightJson.JsonArray.InsertIfNotNull ( int  index,
JsonValue  value 
)
inline

Inserts the given value at the given index in this collection if it is not null.

Parameters
indexThe index where the given value will be inserted.
valueThe value to be inserted into this collection.
Returns
Returns this collection.

Definition at line 104 of file JsonArray.cs.

References LightJson.JsonArray.Insert(), and LightJson.JsonValue.IsNull.

105  {
106  if (!value.IsNull)
107  {
108  Insert(index, value);
109  }
110 
111  return this;
112  }
JsonArray Insert(int index, JsonValue value)
Inserts the given value at the given index in this collection.
Definition: JsonArray.cs:92
Here is the call graph for this function:

◆ Remove()

JsonArray LightJson.JsonArray.Remove ( int  index)
inline

Removes the value at the given index.

Parameters
indexThe index of the value to be removed.
Returns
Return this collection.

Definition at line 119 of file JsonArray.cs.

120  {
121  items.RemoveAt(index);
122  return this;
123  }
List< JsonValue > items
Definition: JsonArray.cs:13

◆ ToString() [1/2]

override string LightJson.JsonArray.ToString ( )

Returns a JSON string representing the state of the array.

The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.

Referenced by LightJson.JsonArray.Clear().

Here is the caller graph for this function:

◆ ToString() [2/2]

string LightJson.JsonArray.ToString ( bool  pretty)

Returns a JSON string representing the state of the array.

The resulting string is safe to be inserted as is into dynamically generated JavaScript or JSON code.

Parameters
prettyIndicates whether the resulting string should be formatted for human-readability.

Field Documentation

◆ Count

int LightJson.JsonArray.Count => items.Count

◆ items

List<JsonValue> LightJson.JsonArray.items = new List<JsonValue>()
private

Definition at line 13 of file JsonArray.cs.

Property Documentation

◆ this[int index]

JsonValue LightJson.JsonArray.this[int index]
getset

The value at the given index.

Parameters
indexThe zero-based index of the value.

Will return JsonValue.Null if the given index is out of range.

Definition at line 22 of file JsonArray.cs.


The documentation for this class was generated from the following file: