/// <summary> /// Set a PsObject array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetPsObjectArray(string key, List <PsObject> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddPsObject(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a boolean array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetBooleanArray(string key, List <bool> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddBoolean(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a (Flash)number array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetNumberArray(string key, List <double> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddNumber(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a long array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetLongArray(string key, List <long> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddLong(value[i]); } SetPsArray(key, array); }
/// <summary> /// Look for a (Flash)number array value in the PsObject. /// </summary> /// <param name="key">Key to look for.</param> /// <returns>Number array value of key.</returns> public List <double> GetNumberArray(string key) { PsArray psa = GetPsArray(key); List <double> list = new List <double>(); for (int i = 0; i < psa.Count; ++i) { list.Add(psa.GetNumber(i)); } return(list); }
/// <summary> /// Look for a PsObject array value in the PsObject. /// </summary> /// <param name="key">Key to look for.</param> /// <returns>PsObject array value of key.</returns> public List <PsObject> GetPsObjectArray(string key) { PsArray psa = GetPsArray(key); List <PsObject> list = new List <PsObject>(); for (int i = 0; i < psa.Count; ++i) { list.Add(psa.GetPsObject(i)); } return(list); }
/// <summary> /// Look for a long array value in the PsObject. /// </summary> /// <param name="key">Key to look for.</param> /// <returns>Long array value of key.</returns> public List <long> GetLongArray(string key) { PsArray psa = GetPsArray(key); List <long> list = new List <long>(); for (int i = 0; i < psa.Count; ++i) { list.Add(psa.GetLong(i)); } return(list); }
/// <summary> /// Look for a boolean array value in the PsObject. /// </summary> /// <param name="key">Key to look for.</param> /// <returns>Boolean array value of key.</returns> public List <bool> GetBoolArray(string key) { PsArray psa = GetPsArray(key); List <bool> list = new List <bool>(); for (int i = 0; i < psa.Count; ++i) { list.Add(psa.GetBoolean(i)); } return(list); }
/// <summary> /// Create a PsObject from Dictionary of string, object pairs. /// </summary> /// <param name="dict">Key-value pairs of data.</param> /// <returns>PsObject containing values from Dictionary.</returns> public static PsObject Create(Dictionary <string, object> dict) { PsObject psobj = new PsObject(); foreach (KeyValuePair <string, object> item in dict) { string key = item.Key; Dictionary <string, object> value = (Dictionary <string, object>)item.Value; int type = (int)value["t"]; switch (type) { case (int)Constants.PsType.Boolean: psobj.SetBoolean(key, Convert.ToBoolean(value["v"])); break; case (int)Constants.PsType.String: psobj.SetString(key, Convert.ToString(value["v"])); break; case (int)Constants.PsType.Integer: psobj.SetInt(key, Convert.ToInt32(value["v"])); break; case (int)Constants.PsType.Long: psobj.SetLong(key, Convert.ToInt64(value["v"])); break; case (int)Constants.PsType.Float: psobj.SetFloat(key, Convert.ToSingle(value["v"])); break; case (int)Constants.PsType.PSObject: psobj.SetPsObject(key, PsObject.Create((Dictionary <string, object>)value["v"])); break; case (int)Constants.PsType.PSArray: psobj.SetPsArray(key, PsArray.Create((object[])value["v"])); break; case (int)Constants.PsType.Number: psobj.SetFloat(key, Convert.ToSingle(value["v"])); break; } } return(psobj); }
/// <summary> /// Create an PsArray from an array of objects. /// </summary> /// <param name="obj">Array of objects.</param> /// <returns></returns> public static PsArray Create(object[] obj) { PsArray psa = new PsArray(); foreach (object o in obj) { Dictionary<string, object> dict = (Dictionary<string, object>)o; int type = (int)dict["t"]; switch (type) { case (int)Constants.PsType.Boolean: psa.AddBoolean(Convert.ToBoolean(dict["v"])); break; case (int)Constants.PsType.String: psa.AddString(Convert.ToString(dict["v"])); break; case (int)Constants.PsType.Integer: psa.AddInt(Convert.ToInt32(dict["v"])); break; case (int)Constants.PsType.Long: psa.AddLong(Convert.ToInt64(dict["v"])); break; case (int)Constants.PsType.Float: psa.AddFloat(Convert.ToSingle(dict["v"])); break; case (int)Constants.PsType.PSObject: psa.AddPsObject(PsObject.Create((Dictionary<string, object>)dict["v"])); break; case (int)Constants.PsType.PSArray: psa.AddPsArray(PsArray.Create((object[])dict["v"])); break; case (int)Constants.PsType.Number: psa.AddNumber(Convert.ToSingle(dict["v"])); break; } } return psa; }
/// <summary> /// Create an PsArray from an array of objects. /// </summary> /// <param name="obj">Array of objects.</param> /// <returns></returns> public static PsArray Create(object[] obj) { PsArray psa = new PsArray(); foreach (object o in obj) { Dictionary <string, object> dict = (Dictionary <string, object>)o; int type = (int)dict["t"]; switch (type) { case (int)Constants.PsType.Boolean: psa.AddBoolean(Convert.ToBoolean(dict["v"])); break; case (int)Constants.PsType.String: psa.AddString(Convert.ToString(dict["v"])); break; case (int)Constants.PsType.Integer: psa.AddInt(Convert.ToInt32(dict["v"])); break; case (int)Constants.PsType.Long: psa.AddLong(Convert.ToInt64(dict["v"])); break; case (int)Constants.PsType.Float: psa.AddFloat(Convert.ToSingle(dict["v"])); break; case (int)Constants.PsType.PSObject: psa.AddPsObject(PsObject.Create((Dictionary <string, object>)dict["v"])); break; case (int)Constants.PsType.PSArray: psa.AddPsArray(PsArray.Create((object[])dict["v"])); break; case (int)Constants.PsType.Number: psa.AddNumber(Convert.ToSingle(dict["v"])); break; } } return(psa); }
/// <summary> /// Add a PsArray to the array. /// </summary> /// <param name="value">PsArray to add.</param> public void AddPsArray(PsArray value) { _content.Add(new PsDataWrapper((int)Constants.PsType.PSArray, value)); }
/// <summary> /// Set a PsObject array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetPsObjectArray(string key, List<PsObject> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddPsObject(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a (Flash)number array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetNumberArray(string key, List<double> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddNumber(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a long array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetLongArray(string key, List<long> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddLong(value[i]); } SetPsArray(key, array); }
/// <summary> /// Set a boolean array in the PsObject. /// </summary> /// <param name="key">Key for value.</param> /// <param name="value">Value to add.</param> public void SetBooleanArray(string key, List<bool> value) { PsArray array = new PsArray(); for (int i = 0; i < value.Count; ++i) { array.AddBoolean(value[i]); } SetPsArray(key, array); }
/// <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 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> /// Add a PsArray to the array. /// </summary> /// <param name="value">PsArray to add.</param> public void AddPsArray(PsArray value) { _content.Add(new PsDataWrapper((int)Constants.PsType.PSArray, value)); }