public LabelEditResult CommitLabelEdit(int row, int column, string newText) { MemberInfo memberInfo = m_Parameters[row]; if (m_ReadOnly) { m_VirtualTreeControl.EndLabelEdit(true); return(LabelEditResult.CancelEdit); } bool refreshTree = false; if (memberInfo.Member.IsClass) { refreshTree = true; if (newText == NULL_VALUE_TEXT) { memberInfo.Value = null; } else { memberInfo.Value = DynamicMethodCompilerCache.CreateInstance(memberInfo.Member.Type); } } else { try { memberInfo.Value = ConversionUtils.ChangeType(newText, memberInfo.Member.Type); } catch { m_VirtualTreeControl.EndLabelEdit(true); return(LabelEditResult.CancelEdit); } } if (refreshTree) { m_VirtualTreeControl.BeginUpdate(); m_RelativeRow = row; m_VirtualTree.ListShuffle = true; m_VirtualTree.Realign(this); m_VirtualTreeControl.EndUpdate(); m_VirtualTree.ListShuffle = false; } PropagateValueUpdateEvent(); return(LabelEditResult.AcceptEdit); }
public string GetText(int row, int column) { MemberInfo memberInfo = m_Parameters[row]; if (column == 0) { return(memberInfo.Member.Name); } if (column == 1) { if (memberInfo.Member.IsClass) { return(memberInfo.Value == null ? NULL_VALUE_TEXT : memberInfo.Member.Type.FullName); } return(ConversionUtils.ChangeType <string>(memberInfo.Value)); } if (column == 2) { return(memberInfo.Member.Type.FullName); } return(string.Empty); }
/// <summary> /// Invokes the method. /// </summary> /// <param name="methodInfo">The method info.</param> /// <param name="object">The @object.</param> /// <param name="bindingFlags">The binding flags.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public static object InvokeMethod(MethodInfo methodInfo, object @object, BindingFlags bindingFlags, IDictionary <string, Parameter> parameters) { if (methodInfo == null) { throw new ArgumentNullException("methodInfo"); } if (@object == null) { throw new ArgumentNullException("object"); } if (parameters == null) { throw new ArgumentNullException("parameters"); } ParameterInfo[] parameterInfos = methodInfo.GetParameters(); if (parameterInfos.Length != parameters.Count) { throw new ReflectionUtilsException(String.Format("'{0}' method parameters count doesn't match the specified parameters count", methodInfo)); } object[] arguments = new object[parameters.Count]; for (int i = 0; i < parameterInfos.Length; i++) { ParameterInfo parameterInfo = parameterInfos[i]; Parameter parameter; if (!parameters.TryGetValue(parameterInfo.Name, out parameter)) { throw new ReflectionUtilsException(String.Format("'{0}' parameter doesn't exist in '{1}' method", parameterInfo.Name, methodInfo)); } arguments[parameterInfo.Position] = ConversionUtils.ChangeType(parameter.Value, parameter.Type); } return(methodInfo.Invoke(@object, bindingFlags, null, arguments, CultureInfo.CurrentCulture)); }