private BindingResult useBindingMethod(object current, StringBuilder pathBuffer, int bufferIndex, ref Binding binding) { System.Type currentType = current.GetType(); // Use reflection to find the named method within the current path object: string mBufferString = pathBuffer.ToString().Substring(0, bufferIndex); MethodInfo mInfo = currentType.GetMethod(mBufferString); if (mInfo == null) { // No matching method was found, abort query: Debug.LogError("[BindingExecutor] Error! Method '" + mBufferString + "' not found in type '" + currentType.Name + "'! Aborting path resolution!"); return(new BindingResult(BindingError.NotFound)); } // Try and create a usable delegate from the method info object, then return that: System.Delegate listener = BindingListener.CreateDelegate(typeof(BindingListener), current, mInfo); if (listener == null) { Debug.LogError("[BindingExecutor] Error! Failed to create delegate from method '" + mInfo.Name + "'! Target method must match the 'BindingListener' specification!"); return(new BindingResult(BindingError.InvalidType)); } // Call the method in question and return successful event resolution: BindingListener listenerMethod = (BindingListener)listener; listenerMethod(ref binding); return(new BindingResult(true)); }