// Disable all XML Comment warnings in this file //
#pragma warning disable 1591
// Credit for this entire class goes to GliderPro. //
using System;
using LavishScriptAPI;
using LavishScriptAPI.Interfaces;
namespace MRBot.IsxEq2.Helpers
{
///
/// Extensions to the LavishScriptObject Class
///
public static class LavishScriptObjectExtensions
{
///
/// Returns the requested string member
///
/// this
/// the member to retrieve
/// LavishScriptObject string member value
public static string GetStringFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: lavishScriptObject.GetValue();
}
}
///
/// Returns the requested string member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of the arguments to pass to the member
/// LavishScriptObject string member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static string GetStringFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: lavishScriptObject.GetValue();
}
}
///
/// Returns the requested Int64 member
///
/// this
/// the member to retrieve
/// LavishScriptObject Int64 member value
public static Int64 GetInt64FromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Returns the requested UInt64 member
///
/// this
/// the member to retrieve
/// LavishScriptObject UInt64 member value
public static UInt64 GetUInt64FromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? 0
: lavishScriptObject.GetValue();
}
}
///
/// Returns the requested Int64 member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject Int64 member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static Int64 GetInt64FromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested float member
///
/// this
/// the member to retrieve
/// LavishScriptObject float member value
public static float GetFloatFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested float member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject float member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static float GetFloatFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested double member
///
/// this
/// the member to retrieve
/// LavishScriptObject double member value
public static double GetDoubleFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested double member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject double member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static double GetDoubleFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? -1
: lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested integer member
///
/// this
/// the member to retrieve
/// LavishScriptObject integer member value
public static int GetIntFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested unsigned integer member
///
/// this
/// the member to retrieve
/// LavishScriptObject integer member value
public static uint GetUIntFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? 0 : lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested integer member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject integer member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static int GetIntFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested unsigned integer member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject integer member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static uint GetUIntFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? 0 : lavishScriptObject.GetValue();
}
}
///
/// Retireves the requested boolean member
///
/// this
/// the member to retrieve
/// LavishScriptObject boolean member value
public static bool GetBoolFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return !LavishScriptObject.IsNullOrInvalid(lavishScriptObject) && lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested boolean member based on the arguments provided
///
/// this
/// the member to retrieve
///
/// LavishScriptObject boolean member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static bool GetBoolFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return !LavishScriptObject.IsNullOrInvalid(lavishScriptObject) && lavishScriptObject.GetValue();
}
}
///
/// Returns the requested Int64 member
///
/// this
/// the member to retrieve
/// LavishScriptObject Int64 member value
public static Int64? GetNullableInt64FromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (Int64?) lavishScriptObject.GetValue();
}
}
///
/// Returns the requested Int64 member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject Int64 member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static Int64? GetNullableInt64FromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (Int64?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested float member
///
/// this
/// the member to retrieve
/// LavishScriptObject float member value
public static float? GetNullableFloatFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (float?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested float member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject float member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static float? GetNullableFloatFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (float?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested double member
///
/// this
/// the member to retrieve
/// LavishScriptObject double member value
public static double? GetNullableDoubleFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (double?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested double member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject double member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static double? GetNullableDoubleFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (double?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested integer member
///
/// this
/// the member to retrieve
/// LavishScriptObject integer member value
public static int? GetNullableIntFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (int?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested integer member based on the arguments provided
///
/// this
/// the member to retrieve
/// string array of arguments to pass to the member
/// LavishScriptObject integer member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static int? GetNullableIntFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (int?) lavishScriptObject.GetValue();
}
}
///
/// Retireves the requested boolean member
///
/// this
/// the member to retrieve
/// LavishScriptObject boolean member value
public static bool? GetNullableBoolFromLSO(this ILSObject obj, string member)
{
using (var lavishScriptObject = obj.GetMember(member))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (bool?) lavishScriptObject.GetValue();
}
}
///
/// Retrieves the requested boolean member based on the arguments provided
///
/// this
/// the member to retrieve
///
/// LavishScriptObject boolean member value
// ReSharper disable MethodOverloadWithOptionalParameter
public static bool? GetNullableBoolFromLSO(this ILSObject obj, string member, params string[] args)
// ReSharper restore MethodOverloadWithOptionalParameter
{
using (var lavishScriptObject = obj.GetMember(member, args))
{
return LavishScriptObject.IsNullOrInvalid(lavishScriptObject)
? null
: (bool?) lavishScriptObject.GetValue();
}
}
}
}