Ejemplo n.º 1
0
        public static bool IsMethodDelegate(IntPtr className, IntPtr methodName)
        {
            string _className  = Marshal.PtrToStringAnsi(className);
            string _methodName = Marshal.PtrToStringAnsi(methodName);

            return(EngineCallbacks.IsMethod(_className, _methodName));
        }
Ejemplo n.º 2
0
        public static string CallFunctionDelegate(IntPtr nameSpace, IntPtr name, IntPtr argv, int argc,
                                                  out bool result)
        {
            string _nameSpace = Marshal.PtrToStringAnsi(nameSpace);
            string _name      = Marshal.PtrToStringAnsi(name);

            string[] strings = null;
            if (argv != IntPtr.Zero)
            {
                strings = StringMarshal.IntPtrToAnsiStringArray(argv, argc);
            }
            return(EngineCallbacks.CallScriptFunction(_nameSpace, _name, strings, out result));
        }
Ejemplo n.º 3
0
        public static void InitializeTypeDictionaries(IEnumerable <Type> types)
        {
            foreach (Type type in types)
            {
                IEnumerable <ConsoleClassAttribute> attributes =
                    type.GetCustomAttributes <ConsoleClassAttribute>(false);
                if (attributes.Any())
                {
                    EngineCallbacks.RegisterType(attributes.First().ConsoleName ?? type.Name, type);
                }

                foreach (MethodInfo methodInfo in type.GetMethods())
                {
                    IEnumerable <ConsoleFunctionAttribute> functionAttributes =
                        methodInfo.GetCustomAttributes <ConsoleFunctionAttribute>(false);
                    if (functionAttributes.Any())
                    {
                        EngineCallbacks.RegisterFunction(functionAttributes.First().FunctionName ?? methodInfo.Name,
                                                         methodInfo);
                    }

                    IEnumerable <ScriptEntryPoint> entryAttribute =
                        methodInfo.GetCustomAttributes <ScriptEntryPoint>(false);

                    if (!entryAttribute.Any())
                    {
                        continue;
                    }

                    if (methodInfo.IsStatic && !methodInfo.GetParameters().Any() &&
                        methodInfo.ReturnType == typeof(void))
                    {
                        mScriptEntryPointMethodInfo = methodInfo;
                    }
                    else
                    {
                        Console.WriteLine("ScriptEntry method: " + methodInfo.Name +
                                          " did not match the necessary signature.");
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static string CallMethodDelegate(IntPtr className, IntPtr classNamespace, uint obj, IntPtr name,
                                                IntPtr argv, int argc,
                                                out bool result)
        {
            string _className      = Marshal.PtrToStringAnsi(className);
            string _classNamespace = Marshal.PtrToStringAnsi(classNamespace);
            string _name           = Marshal.PtrToStringAnsi(name);

            UnknownSimObject objectBaseWrapper = Sim.FindObjectById <UnknownSimObject>(obj);

            string[] strings = { };
            if (argv != IntPtr.Zero)
            {
                strings = StringMarshal.IntPtrToAnsiStringArray(argv, argc);
            }
            string strRes = EngineCallbacks.CallScriptMethod(_className, _classNamespace, objectBaseWrapper, _name, strings,
                                                             out result);

            return(strRes);
        }