public static Int64 GetInt64FromLSO(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <Int64>()); } }
public static double?GetNullableDoubleFromLSO(this ILSObject obj, string member, params string[] args) { using (var lavishScriptObject = obj.GetMember(member, args)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (double?)lavishScriptObject.GetValue <double>()); } }
public static float GetFloat(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <float>()); } }
internal static T GetFromIndexMember <T>(ILSObject obj, string memberName, string lsTypeName, int number, params string[] args) { // argument is 0-based number += 1; if (obj == null || !obj.IsValid) { return(default(T)); } using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName)) { var allargs = PrefixArray(index.LSReference, args); using (var retval = obj.GetMember(memberName, allargs)) { if (LavishScriptObject.IsNullOrInvalid(retval) || retval.GetValue <int>() < number) { return(default(T)); } } var member = GetIndexMember <T>(index, number); return(member); } }
/// <summary> /// Translate an index of a given LavishScript type returned from the given member on the given object to a List of a .NET datatype equivalent. /// </summary> /// <typeparam name="T"></typeparam> /// <param name="obj"></param> /// <param name="memberName"></param> /// <param name="lsTypeName"></param> /// <param name="args"></param> /// <returns></returns> public static List <T> GetListFromMember <T>(this ILSObject obj, string memberName, string lsTypeName, params string[] args) { //var methodName = "GetListFromMember"; //Tracing.SendCallback(methodName, MemberName, LSTypeName); if (obj == null || !obj.IsValid) { return(null); } //Tracing.SendCallback(methodName, "new index"); using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName)) { //Tracing.SendCallback(methodName, "arg condensing"); var allargs = PrefixArray(index.LSReference, args); //Tracing.SendCallback(methodName, "getmember retval"); using (var retval = obj.GetMember(memberName, allargs)) { if (LavishScriptObject.IsNullOrInvalid(retval)) { return(null); } } //Tracing.SendCallback(methodName, "index to list"); var list = IndexToList <T>(index, lsTypeName); //Tracing.SendCallback(methodName, "invalidate"); //Tracing.SendCallback(methodName, "return"); return(list); } }
public static bool GetBoolFromLSO(this ILSObject obj, string member, params string[] args) { using (var lavishScriptObject = obj.GetMember(member, args)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? false : lavishScriptObject.GetValue <bool>()); } }
/// <summary> /// Retrieves the requested unsigned integer member /// </summary> /// <param name="obj">this</param> /// <param name="member">the member to retrieve</param> /// <returns>LavishScriptObject integer member value</returns> public static uint GetUIntFromLSO(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? 0 : lavishScriptObject.GetValue <uint>()); } }
/// <summary> /// Retireves the requested boolean member /// </summary> /// <param name="obj">this</param> /// <param name="member">the member to retrieve</param> /// <returns>LavishScriptObject boolean member value</returns> public static bool GetBoolFromLSO(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(!LavishScriptObject.IsNullOrInvalid(lavishScriptObject) && lavishScriptObject.GetValue <bool>()); } }
public static string GetString(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : lavishScriptObject.GetValue <string>()); } }
public static int GetInt(this ILSObject obj, string member, params string[] args) { using (var lavishScriptObject = obj.GetMember(member, args)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <int>()); } }
public static float?GetNullableFloatFromLSO(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (float?)lavishScriptObject.GetValue <float>()); } }
public static double GetDouble(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <double>()); } }
public static bool?GetNullableBool(this ILSObject obj, string member, params string[] args) { using (var lavishScriptObject = obj.GetMember(member, args)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (bool?)lavishScriptObject.GetValue <bool>()); } }
public static int?GetNullableInt(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? null : (int?)lavishScriptObject.GetValue <int>()); } }
/// <summary> /// Retrieves the requested boolean member based on the arguments provided /// </summary> /// <param name="obj">this</param> /// <param name="member">the member to retrieve</param> /// <param name="args"></param> /// <returns>LavishScriptObject boolean member value</returns> // 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 <bool>()); } }
/// <summary> /// Retrieves the requested integer member based on the arguments provided /// </summary> /// <param name="obj">this</param> /// <param name="member">the member to retrieve</param> /// <param name="args">string array of arguments to pass to the member</param> /// <returns>LavishScriptObject integer member value</returns> // 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 <int>()); } }
internal static List <T> GetListFromMember <T>(ILSObject Obj, string MemberName, string LSTypeName, params string[] Args) { if (Obj == null || !Obj.IsValid) { return(null); } LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName); string[] allargs = PrefixArray <string>(Index.LSReference, Args); LavishScriptObject retval = Obj.GetMember(MemberName, allargs); if (LavishScriptObject.IsNullOrInvalid(retval)) { return(null); } return(IndexToList <T>(Index)); }
internal static T GetFromIndexMember <T>(ILSObject Obj, string MemberName, string LSTypeName, int number, params string[] Args) { // argument is 0-based number += 1; if (Obj == null || !Obj.IsValid) { return(default(T)); } LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName); string[] allargs = PrefixArray <string>(Index.LSReference, Args); LavishScriptObject retval = Obj.GetMember(MemberName, allargs); if (LavishScriptObject.IsNullOrInvalid(retval) || retval.GetValue <int>() < number) { return(default(T)); } return(GetIndexMember <T>(Index, number)); }
internal static List <T> GetListFromMember <T>(ILSObject obj, string memberName, string lsTypeName, params string[] args) { if (obj == null || !obj.IsValid) { return(null); } using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName)) { var allargs = PrefixArray(index.LSReference, args); using (var retval = obj.GetMember(memberName, allargs)) { if (LavishScriptObject.IsNullOrInvalid(retval)) { return(null); } } var list = IndexToList <T>(index, lsTypeName); return(list); } }