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); } }
public static VariantVector FromNet2(object[] value) { VariantVector result = new VariantVector(); foreach (object val in value) { result.Add(FromNet2(val)); } return(result); }
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; }
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); }
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"); } }
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); }
public void ExecuteScript(string code, VariantVector args) { if (Urho3D != null) { if (args == null) { Urho3D.Execute(code); } else { Urho3D.Execute(code, args); } } }
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 + "'")); }
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)); }
public override FBXResult Construct(VariantVector args, fbxvariant returnValue) { return(new FBXResult(false, "Object has no constructor")); }
public override FBXResult Invoke(string methodName, VariantVector args, fbxvariant result) { // Invoke default member here if methodName == ""? return(new FBXResult(false, "Method '" + methodName + "' not found")); }
public override FBXResult Construct(VariantVector args, fbxvariant returnValue) { return new FBXResult(false, "Object has no constructor"); }
public override FBXResult Invoke(string methodName, VariantVector args, fbxvariant result) { // Invoke default member here if methodName == ""? return new FBXResult(false, "Method '" + methodName + "' not found"); }