Table of Contents

Class VariableDictionary

Namespace
Balsam
Assembly
Balsam.Backtester.dll

A dictionary of variables accessible by key or index.

public class VariableDictionary : IDictionary<string, object>, ICollection<KeyValuePair<string, object>>, IEnumerable<KeyValuePair<string, object>>, IEnumerable, ICloneable
Inheritance
VariableDictionary
Implements
Inherited Members
Extension Methods

Properties

Count

Gets the number of items in this variable dictionary.

public int Count { get; }

Property Value

int

this[int]

Gets/sets an element by index.

public object this[int index] { get; set; }

Parameters

index int

Property Value

object

this[string]

Gets/sets an element by key.

public object this[string key] { get; set; }

Parameters

key string

Property Value

object

Keys

Returns a collection containing all the keys.

public ICollection<string> Keys { get; }

Property Value

ICollection<string>

Values

Returns a collection containing all the values.

public ICollection<object> Values { get; }

Property Value

ICollection<object>

Methods

Add(KeyValuePair<string, object>)

Adds the specified KeyValuePair to the dictionary.

public void Add(KeyValuePair<string, object> item)

Parameters

item KeyValuePair<string, object>

Add(string, object)

Adds the specified key and item to the dictionary.

public void Add(string key, object item)

Parameters

key string
item object

Clear()

Clears the dictionary.

public void Clear()

Clone()

Returns a copy of this variable dictionary.

public VariableDictionary Clone()

Returns

VariableDictionary

ContainsKey(string)

Returns true if the specified key is in the dictionary.

public bool ContainsKey(string key)

Parameters

key string

Returns

bool

GetEnumerator()

Returns an enumerator to iterate through the dictionary.

public IEnumerator<KeyValuePair<string, object>> GetEnumerator()

Returns

IEnumerator<KeyValuePair<string, object>>

GetValueAsBoolean(int)

Returns a boolean value at the specified index.

public bool GetValueAsBoolean(int index)

Parameters

index int

Returns

bool

GetValueAsBoolean(string)

Returns a boolean value using the specified key.

public bool GetValueAsBoolean(string key)

Parameters

key string

Returns

bool

GetValueAsDateTime(int)

Returns a DateTime value at the specified index.

public DateTime GetValueAsDateTime(int index)

Parameters

index int

Returns

DateTime

GetValueAsDateTime(string)

Returns a DateTime value using the specifie key.

public DateTime GetValueAsDateTime(string key)

Parameters

key string

Returns

DateTime

GetValueAsDouble(int)

Returns a double value at the specified index.

public double GetValueAsDouble(int index)

Parameters

index int

Returns

double

GetValueAsDouble(string)

Returns a double value using the specified key.

public double GetValueAsDouble(string key)

Parameters

key string

Returns

double

GetValueAsInt32(int)

Returns an integer value at the specified index.

public int GetValueAsInt32(int index)

Parameters

index int

Returns

int

GetValueAsInt32(string)

Returns an integer value using the specified key.

public int GetValueAsInt32(string key)

Parameters

key string

Returns

int

GetValueAsString(int)

Returns a string value at the specified index.

public string GetValueAsString(int index)

Parameters

index int

Returns

string

GetValueAsString(string)

Returns a string value using the specified key.

public string GetValueAsString(string key)

Parameters

key string

Returns

string

GetValueAsType<T>(int)

Returns an object cast to the specified type at the specified index.

public T GetValueAsType<T>(int index)

Parameters

index int

Returns

T

Type Parameters

T

GetValueAsType<T>(string)

Returns an object cast to the specified type using the specified key.

public T GetValueAsType<T>(string key)

Parameters

key string

Returns

T

Type Parameters

T

Load(string)

Loads a json text file representation.

public static VariableDictionary Load(string fileName)

Parameters

fileName string

Returns

VariableDictionary

Merge(VariableDictionary, bool, bool)

Merges the specified variable dictionary with the existing one, optionally overwriting any existing keys.

public void Merge(VariableDictionary variableDictionary, bool overwrite = false, bool throwOnDuplicateKey = false)

Parameters

variableDictionary VariableDictionary
overwrite bool
throwOnDuplicateKey bool

Remove(string)

Removes the item with the specified key from the dictionary.

public bool Remove(string key)

Parameters

key string

Returns

bool

Save(string)

Saves this DataSource to a json text representation.

public void Save(string fileName)

Parameters

fileName string

SetProperties(object)

Sets the properties of the specified target object to the values contained in this dictionary.

public void SetProperties(object target)

Parameters

target object

ToString()

Returns a json-like string representation of this variable dictionary.

public override string ToString()

Returns

string