public void MethodWithParameters() { var type = module.GetType("Com.Mypackage.Foo"); var @class = new ManagedClassGen(type, options); var method = new ManagedMethod(@class, type.Methods.First(m => m.Name == "BarWithParams")); Assert.IsTrue(method.Validate(new CodeGenerationOptions(), new GenericParameterDefinitionList()), "method.Validate failed!"); Assert.AreEqual("(ZID)Ljava/lang/String;", method.JniSignature); Assert.AreEqual("java.lang.String", method.Return); Assert.AreEqual("System.String", method.ManagedReturn); var parameter = method.Parameters [0]; Assert.AreEqual("a", parameter.Name); Assert.AreEqual("bool", parameter.Type); Assert.AreEqual("boolean", parameter.JavaType); Assert.AreEqual("Z", parameter.JniType); parameter = method.Parameters [1]; Assert.AreEqual("b", parameter.Name); Assert.AreEqual("int", parameter.Type); Assert.AreEqual("int", parameter.JavaType); Assert.AreEqual("I", parameter.JniType); parameter = method.Parameters [2]; Assert.AreEqual("c", parameter.Name); Assert.AreEqual("double", parameter.Type); Assert.AreEqual("double", parameter.JavaType); Assert.AreEqual("D", parameter.JniType); }
// Property from getter method public ManagedProperty(ManagedMethod getter, string name) { Getter = getter; Name = name; Parent = getter.Parent; Parent.Properties.Add(this); getter.Property = this; }
public void Method_Matches_True() { var type = module.GetType("Com.Mypackage.Foo"); var @class = new ManagedClassGen(type, options); var unknownTypes = type.Methods.First(m => m.Name == "UnknownTypes"); var methodA = new ManagedMethod(@class, unknownTypes); var methodB = new ManagedMethod(@class, unknownTypes); Assert.IsTrue(methodA.Matches(methodB), "Methods should match!"); }
//System.Reflection.PropertyInfo prop; /// <summary> /// ManagedProperty インスタンスを PropertyInfo から作成します。 /// </summary> /// <param name="prop">PropertyInfo</param> public ManagedProperty(System.Reflection.PropertyInfo prop) { //this.prop=prop; System.Type type = prop.ReflectedType; if (prop.CanRead) { this[":propget:"] = new ManagedMethod(type, prop.GetGetMethod()); } if (prop.CanWrite) { this[":propput:"] = new ManagedMethod(type, prop.GetSetMethod()); } }
public void Method_Matches_False() { var type = module.GetType("Com.Mypackage.Foo"); var @class = new ManagedClassGen(type, options); var unknownTypesA = type.Methods.First(m => m.Name == "UnknownTypes"); var unknownTypesB = type.Methods.First(m => m.Name == "UnknownTypesReturn"); unknownTypesB.Name = "UnknownTypes"; var methodA = new ManagedMethod(@class, unknownTypesA); var methodB = new ManagedMethod(@class, unknownTypesB); //Everything the same besides return type Assert.IsFalse(methodA.Matches(methodB), "Methods should not match!"); }
public void Method() { var type = module.GetType("Com.Mypackage.Foo"); var @class = new ManagedClassGen(type, options); var method = new ManagedMethod(@class, type.Methods.First(m => m.Name == "Bar")); Assert.IsTrue(method.Validate(new CodeGenerationOptions(), new GenericParameterDefinitionList()), "method.Validate failed!"); Assert.AreEqual("public", method.Visibility); Assert.AreEqual("void", method.Return); Assert.AreEqual("System.Void", method.ReturnType); Assert.AreEqual("Bar", method.Name); Assert.AreEqual("bar", method.JavaName); Assert.AreEqual("()V", method.JniSignature); Assert.IsFalse(method.IsAbstract); Assert.IsFalse(method.IsFinal); Assert.IsFalse(method.IsStatic); Assert.IsNull(method.Deprecated); }
public ManagedDelegate(object obj, ManagedMethod meth) : base(meth.type, meth.methods) { this.obj = obj; }