/// <summary> /// Retrieves the requested double member /// </summary> /// <param name="obj">this</param> /// <param name="member">the member to retrieve</param> /// <returns>LavishScriptObject double member value</returns> public static double GetDoubleFromLSO(this ILSObject obj, string member) { using (var lavishScriptObject = obj.GetMember(member)) { return(LavishScriptObject.IsNullOrInvalid(lavishScriptObject) ? -1 : lavishScriptObject.GetValue <double>()); } }
/// <summary> /// Returns the requested Int64 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 Int64 member value</returns> // 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 <Int64>()); } }
/// <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?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 <bool>()); } }
/// <summary> /// Translate an index of a given LavishScript type returned from the given method on the given object to a List of a .NET datatype equivalent. /// </summary> /// <param name="obj"></param> /// <param name="methodName"></param> /// <param name="lsTypeName"></param> /// <param name="args"></param> /// <typeparam name="T"></typeparam> /// <returns></returns> public static List <T> GetListFromMethod <T>(this ILSObject obj, string methodName, string lsTypeName, params string[] args) { //string methodName = "GetListFromMethod"; //Tracing.SendCallback(methodName, MethodName, LSTypeName); if (obj == null || !obj.IsValid) { return(null); } //Tracing.SendCallback(methodName, "Create new LSO of index. Type: ", LSTypeName); using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName)) { //Tracing.SendCallback(methodName, "Collapsing Args[]"); string[] allargs; if (args.Length > 0) { allargs = PrefixArray(index.LSReference, args); } else { allargs = new string[1]; allargs[0] = index.LSReference; } //Tracing.SendCallback(methodName, "Execute method, name: ", MethodName); if (!obj.ExecuteMethod(methodName, allargs)) { return(null); } //Tracing.SendCallback(methodName, "Get member Used"); using (var used = index.GetMember("Used")) { //Tracing.SendCallback(methodName, "LSO.IsNullOrInvalid (used)"); if (LavishScriptObject.IsNullOrInvalid(used)) { return(null); } } //Tracing.SendCallback(methodName, "IndexToList"); var list = IndexToList <T>(index, lsTypeName); //Tracing.SendCallback(methodName, "Returning"); return(list); } }
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 List <T> GetListFromMethod <T>(ILSObject obj, string methodName, string lsTypeName, params string[] args) { if (obj == null || !obj.IsValid) { return(null); } using (var index = LavishScript.Objects.NewObject("index:" + lsTypeName)) { string[] allargs; if (args.Length > 0) { allargs = PrefixArray(index.LSReference, args); } else { allargs = new string[1]; allargs[0] = index.LSReference; } if (!obj.ExecuteMethod(methodName, allargs)) { return(null); } using (var used = index.GetMember("Used")) { if (LavishScriptObject.IsNullOrInvalid(used)) { return(null); } } var list = IndexToList <T>(index, lsTypeName); return(list); } }
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); } }