public void UpdateConfiguration(sUpdateConfigurationsCall call) { MethodInfo mi = null; object[] pars = new object[call.Parameters.Length]; foreach (MethodInfo m in this.GetType().GetMethods()) { if (m.Name == call.MethodName) { if (m.GetParameters().Length == call.Parameters.Length) { bool isvalid = false; int x = 0; foreach (ParameterInfo pi in m.GetParameters()) { bool found = false; foreach (NameValuePair nvp in call.Parameters) { if (nvp.Name == pi.Name) { found = true; pars[x] = nvp.Value; found = true; x++; } } if (!found) { isvalid = false; break; } } if (isvalid) { mi = m; break; } } } } if (mi == null) { throw new Exception("Unable to update configuration for dialplan [" + Name + "], no valid method found"); } mi.Invoke(this, pars); }
public void UpdateConfiguration(sUpdateConfigurationsCall call) { MethodInfo mi=null; object[] pars = new object[call.Parameters.Length]; foreach (MethodInfo m in this.GetType().GetMethods()) { if (m.Name == call.MethodName) { if (m.GetParameters().Length == call.Parameters.Length) { bool isvalid = false; int x = 0; foreach (ParameterInfo pi in m.GetParameters()) { bool found = false; foreach (NameValuePair nvp in call.Parameters) { if (nvp.Name == pi.Name) { found = true; pars[x] = nvp.Value; found = true; x++; } } if (!found) { isvalid = false; break; } } if (isvalid) { mi = m; break; } } } } if (mi == null) throw new Exception("Unable to update configuration for dialplan [" + Name + "], no valid method found"); mi.Invoke(this, pars); }