Exemplo n.º 1
0
        static void Main()
        {
            /* This doesn't do anything useful except give me a place to test wrapper functions -- CyberTech */

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Form1());

            InnerSpace.Echo("ISXEVEWrapperTest: Begin");

            using (new FrameLock(true))
            {
                LavishScriptObject _Me = LavishScript.Objects.GetObject("Me");
                InnerSpace.Echo("Name: " + _Me.GetMember("Name"));

                //Extension Ext = new Extension();
                //InnerSpace.Echo("Name: " + Ext.Me.Name);
                //    InnerSpace.Echo("Nearest Stargate (fails in station): " + Ext.Entity("Stargate").Name);

                //    InnerSpace.Echo("Undocking Method 1...");
                //    //Ext.EVE().Execute(ExecuteCommand.CmdExitStation);

                //    InnerSpace.Echo("Undocking Method 2...");
                //    //Ext.EVE().Execute("CmdExitStation");

                //    InnerSpace.Echo(Ext.ISXEVE().SecsToString(500));

                //Extension Ext = new Extension();
                //InnerSpace.Echo(Ext.Me.Name.ToString(CultureInfo.CurrentCulture));
                //InnerSpace.Echo(Me.Ship.ToString(CultureInfo.CurrentCulture));
            }
            InnerSpace.Echo("ISXEVEWrapperTest: End");
        }
Exemplo n.º 2
0
        internal static T GetFromIndexMethod <T>(ILSObject Obj, string MethodName, string LSTypeName, int number, params string[] Args)
        {
            // argument is 0-based
            number += 1;

            if (Obj == null || !Obj.IsValid || number <= 0)
            {
                return(default(T));
            }

            LavishScriptObject Index = LavishScript.Objects.NewObject("index:" + LSTypeName);

            string[] allargs = PrefixArray <string>(Index.LSReference, Args);

            Obj.ExecuteMethod(MethodName, allargs);

            LavishScriptObject used = Index.GetMember("Used");

            // if it failed or we want one off the end, return
            if (LavishScriptObject.IsNullOrInvalid(used) || used.GetValue <int>() < number)
            {
                return(default(T));
            }

            return(GetIndexMember <T>(Index, number));
        }
Exemplo n.º 3
0
        private static List <T> IndexToStructList <T>(LavishScriptObject index)
        {
            var list  = new List <T>();
            var count = index.GetMember <int>("Used");

            for (var i = 1; i <= count; i++)
            {
                list.Add(index.GetIndex <T>(i.ToString(CultureInfo.CurrentCulture)));
            }

            return(list);
        }
Exemplo n.º 4
0
        private static List <T> IndexToStructList <T>(LavishScriptObject Index)
        {
            List <T> List  = new List <T>();
            int      Count = Index.GetMember <int>("Used");

            for (int i = 1; i <= Count; i++)
            {
                List.Add(Index.GetIndex <T>(i.ToString()));
            }

            return(List);
        }
Exemplo n.º 5
0
        private static List <T> IndexToLavishScriptObjectList <T>(LavishScriptObject Index)
        {
            List <T> List  = new List <T>();
            int      Count = Index.GetMember <int>("Used");

            ConstructorInfo constructor = typeof(T).GetConstructor(new Type[] { typeof(LavishScriptObject) });

            for (int i = 1; i <= Count; i++)
            {
                List.Add((T)constructor.Invoke(new object[] { Index.GetIndex(i.ToString()) }));
            }

            return(List);
        }
Exemplo n.º 6
0
        private static List <T> IndexToLavishScriptObjectList <T>(LavishScriptObject index, string lsTypeName)
        {
            //string methodName = "IndexToLSOList";
            //Tracing.SendCallback(methodName, LSTypeName);

            //Tracing.SendCallback(methodName, "getmember Used");
            var list  = new List <T>();
            var count = index.GetMember <int>("Used");

            if (count == 0)
            {
                return(list);
            }

            //Tracing.SendCallback(methodName, "get constructor info");
            var constructorInfo = GetConstructorInfoForType(typeof(T));

            //Tracing.SendCallback(methodName, "loop add items");
            for (var i = 1; i <= count; i++)
            {
                var objectLso = index.GetIndex(i.ToString(CultureInfo.CurrentCulture));

                if (LavishScriptObject.IsNullOrInvalid(objectLso))
                {
                    Tracing.SendCallback(String.Format(CultureInfo.InvariantCulture, "Error: Index contains invalid LSO. NewObject will fail; aborting."));
                    return(list);
                }

                var objectId = objectLso.GetString("ID");

                if (objectId == null)
                {
                    Tracing.SendCallback(String.Format(CultureInfo.InvariantCulture, "Error: LStype \"{0}\" has no ID member. NewObject will fail; aborting.", lsTypeName));
                    return(list);
                }

                if (objectId == string.Empty)
                {
                    Tracing.SendCallback(String.Format(CultureInfo.InvariantCulture, "Error: LStype \"{0}\" has an ID member but it is returning an empty string. NewObject will fail; aborting.", lsTypeName));
                    return(list);
                }

                var lsObject = LavishScript.Objects.NewObject(lsTypeName, objectId);
                var item     = (T)constructorInfo.Invoke(new object[] { lsObject });
                list.Add(item);
            }

            return(list);
        }
Exemplo n.º 7
0
        private static List <T> IndexToLavishScriptObjectList <T>(LavishScriptObject index, string lsTypeName)
        {
            var list  = new List <T>();
            var count = index.GetMember <int>("Used");

            if (count == 0)
            {
                return(list);
            }

            var constructor = typeof(T).GetConstructor(new[] { typeof(LavishScriptObject) });

            Trace.WriteLine(count);
            for (var i = 1u; i <= count; i++)
            {
                var objectLso = index.GetIndex(i.ToString(CultureInfo.InvariantCulture));

                if (LavishScriptObject.IsNullOrInvalid(objectLso))
                {
                    return(list);
                }

                var objectId = objectLso.GetStringFromLSO("ID");
                Trace.WriteLine(i + " " + objectId);
                if (objectId == null)
                {
                    return(list);
                }

                if (objectId == string.Empty)
                {
                    return(list);
                }

                var lsObject = LavishScript.Objects.NewObject(lsTypeName, objectId);
                if (constructor != null)
                {
                    var item = (T)constructor.Invoke(new object[] { lsObject });
                    list.Add(item);
                }
            }

            return(list);
        }
Exemplo n.º 8
0
        internal static List <T> GetListFromMethod <T>(ILSObject Obj, string MethodName, 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);

            Obj.ExecuteMethod(MethodName, allargs);

            LavishScriptObject used = Index.GetMember("Used");

            if (LavishScriptObject.IsNullOrInvalid(used))
            {
                return(null);
            }

            return(IndexToList <T>(Index));
        }