Ejemplo n.º 1
0
        public static T Call <T>(Hash hash, params InputArgument[] arguments)
        {
            ulong[] args = new ulong[arguments.Length];
            for (int i = 0; i < arguments.Length; ++i)
            {
                args[i] = arguments[i].data;
            }

            var task = new SHVDN.NativeFunc((ulong)hash, args);

            SHVDN.ScriptDomain.CurrentDomain.ExecuteTask(task);

            unsafe
            {
                // The result will be null when this method is called from a thread other than the main thread
                if (task.Result == null)
                {
                    throw new InvalidOperationException("Native.Function.Call can only be called from the main thread.");
                }

                var type = typeof(T);
                if (type.IsEnum || type.IsPrimitive || type == typeof(Vector3) || type == typeof(Vector2))
                {
                    return(NativeHelperGeneric <T> .ObjectFromNativeGeneric(task.Result));
                }
                else
                {
                    return((T)ObjectFromNative(type, task.Result));
                }
            }
        }
Ejemplo n.º 2
0
 public T GetResult <T>()
 {
     unsafe
     {
         var type = typeof(T);
         if (type.IsEnum || type.IsPrimitive || type == typeof(Vector3) || type == typeof(Vector2))
         {
             return(NativeHelperGeneric <T> .ObjectFromNativeGeneric((ulong *)data));
         }
         else
         {
             return((T)Function.ObjectFromNative(type, (ulong *)data));
         }
     }
 }