Esempio n. 1
0
 public static void To(VariantVector target, List <VariantVectorRecord> records)
 {
     foreach (VariantVectorRecord rec in records)
     {
         Variant v = new Variant();
         v.FromString(rec.Type.ToString(), rec.Value);
         target.Add(v);
     }
 }
Esempio n. 2
0
        public static VariantVector FromNet2(object[] value)
        {
            VariantVector result = new VariantVector();

            foreach (object val in value)
            {
                result.Add(FromNet2(val));
            }
            return(result);
        }
Esempio n. 3
0
        public override FBXResult Construct(VariantVector args, fbxvariant returnValue)
        {
            FBXResult result = Converter.InvokeOverload(this.typeObject, this.typeObject.GetConstructors(), "*ctor*", args, returnValue);
            if (!result.success)
                return result;

            /*dynamic newInstance = new JSObject(returnValue.get_object());
            newInstance._cs_prototype = this.typeObject;*/
            return result;
        }
Esempio n. 4
0
        public static List <VariantVectorRecord> From(VariantVector vector)
        {
            List <VariantVectorRecord> ret = new List <VariantVectorRecord>();

            for (int i = 0; i < vector.Count; ++i)
            {
                ret.Add(new VariantVectorRecord {
                    Type = (VariantType)vector[i].GetVarTypeID(), Value = vector[i].ToString()
                });
            }
            return(ret);
        }
Esempio n. 5
0
 public override FBXResult Invoke(string methodName, VariantVector args, fbxvariant result)
 {
     if (methodName == "")
     {
         IEnumerable <MethodInfo> methods = from method in this.methodObject.obj.GetType().GetMethods() where method.Name == this.methodObject.name select method;
         return(Converter.InvokeOverload(this.methodObject.obj, methods, this.methodObject.name, args, result));
     }
     else
     {
         throw new Exception("Internal error - execution should never reach here");
     }
 }
Esempio n. 6
0
        public override FBXResult Construct(VariantVector args, fbxvariant returnValue)
        {
            FBXResult result = Converter.InvokeOverload(this.typeObject, this.typeObject.GetConstructors(), "*ctor*", args, returnValue);

            if (!result.success)
            {
                return(result);
            }

            /*dynamic newInstance = new JSObject(returnValue.get_object());
             * newInstance._cs_prototype = this.typeObject;*/
            return(result);
        }
Esempio n. 7
0
 public void ExecuteScript(string code, VariantVector args)
 {
     if (Urho3D != null)
     {
         if (args == null)
         {
             Urho3D.Execute(code);
         }
         else
         {
             Urho3D.Execute(code, args);
         }
     }
 }
Esempio n. 8
0
        public static FBXResult InvokeOverload(Object obj, IEnumerable <MethodBase> candidates, string name, VariantVector args, fbxvariant result, out object resultObj)
        {
            resultObj = null;
            System.Collections.Generic.List <object> convertedArgs = new System.Collections.Generic.List <object>();

            // todo: cache conversion results for more speed
            foreach (MethodBase candidate in candidates)
            {
                ParameterInfo[] targetParameters = candidate.GetParameters();
                int             count            = Math.Min(args.Count(), targetParameters.Length);
                object[]        converted        = new object[count];
                bool            ok = true;

                for (int i = 0; i < count; i++)
                {
                    fbxvariant    sourceValue     = args[i];
                    ParameterInfo targetParameter = targetParameters[i];
                    if (!ToNet(sourceValue, targetParameter.ParameterType, out converted[i]).success)
                    {
                        ok = false;
                        break;
                    }
                }

                if (ok)
                {
                    try
                    {
                        // todo: this is ugly, factor out
                        if (name != "*ctor*")
                        {
                            resultObj = candidate.Invoke(obj, converted);
                        }
                        else
                        {
                            resultObj = ((ConstructorInfo)candidate).Invoke(converted);
                        }
                    }
                    catch (Exception e)
                    {
                        return(new FBXResult(false, "Error invoking '" + name + "'. Details: " + e));
                    }
                    return(FromNet(resultObj, result));
                }
            }

            return(new FBXResult(false, "Could not find matching overload for '" + name + "'"));
        }
Esempio n. 9
0
        public static FBXResult InvokeOverload(Object obj, IEnumerable <MethodBase> candidates, string name, VariantVector args, fbxvariant result)
        {
            object resultObj;

            return(InvokeOverload(obj, candidates, name, args, result, out resultObj));
        }
Esempio n. 10
0
 public override FBXResult Construct(VariantVector args, fbxvariant returnValue)
 {
     return(new FBXResult(false, "Object has no constructor"));
 }
Esempio n. 11
0
 public override FBXResult Invoke(string methodName, VariantVector args, fbxvariant result)
 {
     // Invoke default member here if methodName == ""?
     return(new FBXResult(false, "Method '" + methodName + "' not found"));
 }
Esempio n. 12
0
 public override FBXResult Construct(VariantVector args, fbxvariant returnValue)
 {
     return new FBXResult(false, "Object has no constructor");
 }
Esempio n. 13
0
 public override FBXResult Invoke(string methodName, VariantVector args, fbxvariant result)
 {
     // Invoke default member here if methodName == ""?
     return new FBXResult(false, "Method '" + methodName + "' not found");
 }