internal static _Value Value() { if (_ValueFunc == null) { _ValueFunc = (_Value)Marshal.GetDelegateForFunctionPointer( Torque3D.DllLoadUtils.GetProcAddress( Torque3D.Torque3DLibHandle, "fnSettings_value"), typeof(_Value)); } return(_ValueFunc); }
internal static _Value Value() { if (_ValueFunc == null) { _ValueFunc = (_Value)Marshal.GetDelegateForFunctionPointer( NativeLibrary.GetExport( Torque3D.Torque3DLibHandle, "fnSettings_value"), typeof(_Value)); } return(_ValueFunc); }
/// <summary> /// Removes an enumerated type and returns the new value /// </summary> public static T Remove<T>(this Enum value, T remove) { Type type = value.GetType(); //determine the values object result = value; var parsed = new _Value(remove, type); if (parsed.Signed is long) { result = Convert.ToInt64(value) & ~(long) parsed.Signed; } else if (parsed.Unsigned is ulong) { result = Convert.ToUInt64(value) & ~(ulong) parsed.Unsigned; } //return the final value return (T) Enum.Parse(type, result.ToString()); }
/// <summary> /// Checks if an enumerated type contains a value. /// </summary> /// <typeparam name="T">The enum type.</typeparam> /// <param name="value">The enum to check.</param> /// <param name="check">Value to check for.</param> /// <returns>True if the enum has the value(s), false otherwise.</returns> public static bool Has <T>(this Enum value, T check) { Type type = value.GetType(); //determine the values var parsed = new _Value(check, type); if (parsed.Signed.HasValue) //if (parsed.Signed is long) { return((Convert.ToInt64(value) & (long)parsed.Signed) == (long)parsed.Signed); } if (parsed.Unsigned.HasValue) //if (parsed.Unsigned is ulong) { return((Convert.ToUInt64(value) & (ulong)parsed.Unsigned) == (ulong)parsed.Unsigned); } return(false); }
public static T Add <T>(this Enum value, T add) { Type type = value.GetType(); object result = value; var parsed = new _Value(add, type); if (parsed.Signed is long) { result = Convert.ToInt64(value) | (long)parsed.Signed; } else if (parsed.Unsigned is ulong) { result = Convert.ToUInt64(value) | (ulong)parsed.Unsigned; } return((T)Enum.ToObject(type, result)); }
/// <summary> /// Includes an enumerated type and returns the new value /// </summary> public static T Include <T>(this Enum value, T append) { Type type = value.GetType(); //determine the values object result = value; _Value parsed = new _Value(append, type); if (parsed.Signed is long) { result = Convert.ToInt64(value) | (long)parsed.Signed; } else if (parsed.Unsigned is ulong) { result = Convert.ToUInt64(value) | (ulong)parsed.Unsigned; } //return the final value return((T)Enum.Parse(type, result.ToString())); }
/// <summary> /// Checks if an enumerated type contains a value /// </summary> /// <typeparam name="T"> /// </typeparam> /// <param name="value"> /// The value. /// </param> /// <param name="check"> /// The check. /// </param> /// <returns> /// The has. /// </returns> public static bool Has <T>(this Enum value, T check) { var type = value.GetType(); // determine the values object result = value; var parsed = new _Value(check, type); if (parsed.Signed is long) { return((Convert.ToInt64(value) & (long)parsed.Signed) == (long)parsed.Signed); } else if (parsed.Unsigned is ulong) { return((Convert.ToUInt64(value) & (ulong)parsed.Unsigned) == (ulong)parsed.Unsigned); } else { return(false); } }
set => Set(ref _Value, value);