protected internal virtual void discover(Type clazz, String propertyName) { /* * this is gross and linear, but it keeps it straightforward. */ try { propertyUsed = propertyName; property = introspector.getProperty(clazz, propertyUsed); if (property != null) { return; } /* * now the convenience, flip the 1st character */ propertyUsed = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1); property = introspector.getProperty(clazz, propertyUsed); if (property != null) { return; } propertyUsed = propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1); property = introspector.getProperty(clazz, propertyUsed); if (property != null) { return; } // check for a method that takes no arguments propertyUsed = propertyName; method = introspector.getMethod(clazz, propertyUsed, new Object[0]); if (method != null) { return; } // check for a method that takes no arguments, flipping 1st character propertyUsed = propertyName.Substring(0, 1).ToUpper() + propertyName.Substring(1); method = introspector.getMethod(clazz, propertyUsed, new Object[0]); if (method != null) { return; } propertyUsed = propertyName.Substring(0, 1).ToLower() + propertyName.Substring(1); method = introspector.getMethod(clazz, propertyUsed, new Object[0]); if (method != null) { return; } } catch (Exception e) { rlog.error("PROGRAMMER ERROR : PropertyExector() : " + e); } }
public void Test_Evaluate() { RuntimeServices rs = RuntimeSingleton.RuntimeServices; Introspector i = new Introspector(rs); MethodInfo mi = i.getMethod(typeof(VelocityTest), "Test_Evaluate", null); Assertion.AssertNotNull("Expected to find VelocityTest.Test_Evaluate", mi); Assertion.Assert("method not found", mi.ToString().Equals("Void Test_Evaluate()")); mi = i.getMethod(typeof(ExtendedProperties), "GetString", new Object[] { "parm1", "parm2" }); Assertion.AssertNotNull("Expected to find ExtendedProperties.GetString(String, String)", mi); Assertion.Assert("method not found", mi.ToString().Equals("System.String GetString(System.String, System.String)")); }
/// <summary> /// Default constructor. /// </summary> public GetExecutor(RuntimeLogger r, Introspector i, Type c, String key) { rlog = r; args[0] = key; // NOTE: changed from get to get to get_Item - assumption is that get would be converted to an indexer in .Net // to keep some resembalance to the Java version, look for "Get" and "get" methods as well (both cases for .Net style and java) method = i.getMethod(c, "get_Item", args); if (method == null) { method = i.getMethod(c, "Get", args); if (method == null) { method = i.getMethod(c, "get", args); } } }