/// <summary> /// This function tries to retrieve the data value and returns true if this was succesful /// </summary> /// <param name="key">The key at which data is stored</param> /// <param name="data">The string to which to write the data to</param> /// <param name="inherit"></param> /// <returns>True if the data was succesfully retrieved, false otherwise</returns> public bool TryGetData(string key, out dynamic data, bool inherit = false) { try { data = MtaShared.GetElementData(this.MTAElement, key, inherit); return(true); } catch (Exception) { data = ""; return(false); } }
/// <summary> /// This function tries to retrieve the data value and returns true if this was succesful /// </summary> /// <typeparam name="T"></typeparam> /// <param name="key">The key at which data is stored</param> /// <param name="data">The string to which to write the data to</param> /// <param name="inherit"></param> /// <returns>True if the data was succesfully retrieved, false otherwise</returns> public bool TryGetData <T>(string key, out T data, bool inherit = false) { try { data = (T)MtaShared.GetElementData(this.MTAElement, key, inherit); return(true); } catch (Exception) { data = default(T); return(false); } }
/// <summary> /// Gets element data /// </summary> /// <param name="key"></param> /// <param name="inherit"></param> /// <returns></returns> public dynamic GetData(string key, bool inherit = false) { return(MtaShared.GetElementData(this.MTAElement, key, inherit)); }