/// <summary> /// Trys to get a CVar. /// <para>Returns true if the CVar was found.</para> /// </summary> /// <typeparam name="T">The datatype of the CVar.</typeparam> /// <param name="name">The name of the CVar.</param> /// <param name="value">The value of the CVar.</param> /// <returns>Returns whether or not the CVar was found.</returns> public static bool TryGetCVar <T>(string name, out T value) { value = default(T); CVar cvar; bool success = CVars.TryGetValue(name, out cvar); value = (T)cvar.value; return(success); }
/// <summary> /// Attemps to retrieve a CVar. /// </summary> /// <typeparam name="T">The datatype of the CVar.</typeparam> /// <param name="name">The name of the CVar.</param> /// <returns>The CVar, as it's actual datatype.</returns> public static T GetCVar <T>(string name) { if (name == null) { throw new ArgumentNullException("name"); } CVar cvar; if (CVars.TryGetValue(name, out cvar)) { return((T)cvar.value); } else { throw new Exception(String.Format("CVar \"{0}\" does not exist!", name)); } }