/// <summary> /// Creates a List of objects from the array. /// </summary> /// <returns>List of objects.</returns> public List <object> ToArrayObject() { List <object> ret = new List <object>(); for (int i = 0; i < _content.Count; ++i) { PsDataWrapper data = _content[i]; if (data.v is PsObject) { ret.Add((data.v as PsObject).ToObject()); } else if (data.v is PsArray) { ret.Add((data.v as PsArray).ToArrayObject()); } else { ret.Add(data); } } return(ret); }
/// <summary> /// Create a raw object for JSON serialization. /// </summary> /// <returns>Object from PsObject.</returns> public object ToObject() { Dictionary <string, object> ret = new Dictionary <string, object>(); string[] keys = new string[_content.Keys.Count]; _content.Keys.CopyTo(keys, 0); for (int i = 0; i < keys.Length; ++i) { string key = keys[i]; PsDataWrapper data = _content[key]; if (data.v is PsObject) { Hashtable hash = new Hashtable(2); hash.Add(Constants.TYPE_FLAG, (int)Constants.PsType.PSObject); hash.Add(Constants.VALUE_FLAG, (data.v as PsObject).ToObject()); ret[key] = hash; } else if (data.v is PsArray) { Hashtable hash = new Hashtable(2); hash.Add(Constants.TYPE_FLAG, (int)Constants.PsType.PSArray); hash.Add(Constants.VALUE_FLAG, (data.v as PsArray).ToArrayObject()); ret[key] = hash; } else { ret[key] = data; } } return(ret); }
/// <summary> /// Set a PsArray in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetPsArray(string key, PsArray value) { _content[key] = new PsDataWrapper((int)Constants.PsType.PSArray, value); }
/// <summary> /// Set a PsObject in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetPsObject(string key, PsObject value) { _content[key] = new PsDataWrapper((int)Constants.PsType.PSObject, value); }
/// <summary> /// Set a long in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetLong(string key, long value) { _content[key] = new PsDataWrapper((int)Constants.PsType.Long, value); }
/// <summary> /// Set a float in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetFloat(string key, float value) { _content[key] = new PsDataWrapper((int)Constants.PsType.Float, value); }
/// <summary> /// Set a boolean in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetBoolean(string key, bool value) { _content[key] = new PsDataWrapper((int)Constants.PsType.Boolean, value); }
/// <summary> /// Set a int in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetInt(string key, int value) { _content[key] = new PsDataWrapper((int)Constants.PsType.Integer, value); }