public static CodeGenerateSystem.Controls.NodeListAttributeClass AddFieldNode(CodeGenerateSystem.Controls.NodesContainerControl.ContextMenuFilterData filterData, FieldInfo fieldInfo, Type parentClassType, CodeGenerateSystem.Controls.NodeListControl hostNodesList, CodeDomNode.PropertyInfoAssist.enDirection direction, EngineNS.ECSType csType, string attributeName, CodeDomNode.MethodInfoAssist.enHostType hostType) { var att = EngineNS.Rtti.AttributeHelper.GetCustomAttribute(fieldInfo, attributeName, true); if (att == null) { return(null); } var path = EngineNS.Rtti.AttributeHelper.GetCustomAttributePropertyValue(att, "Path")?.ToString(); if (string.IsNullOrEmpty(path)) { path = EngineNS.Rtti.RttiHelper.GetAppTypeString(fieldInfo.ReflectedType) + "." + fieldInfo.Name; } var description = EngineNS.Rtti.AttributeHelper.GetCustomAttributePropertyValue(att, "Description").ToString(); var csParam = new CodeDomNode.PropertyNode.PropertyNodeConstructionParams() { CSType = csType, ConstructParam = "", PropertyInfo = CodeDomNode.PropertyNode.GetAssistFromFieldInfo(fieldInfo, parentClassType, direction, path, hostType), }; var mpattr = fieldInfo.GetCustomAttributes(typeof(EngineNS.Editor.MacrossPanelPathAttribute), false); if (mpattr.Length > 0) { path = ((EngineNS.Editor.MacrossPanelPathAttribute)mpattr[0]).Path; } else { path = path.Replace('.', '/'); } var displayattr = fieldInfo.GetCustomAttributes(typeof(System.ComponentModel.DisplayNameAttribute), false); if (displayattr.Length > 0) { csParam.DisplayName = ((System.ComponentModel.DisplayNameAttribute)displayattr[0]).DisplayName; } return(hostNodesList.AddNodesFromType(filterData, typeof(CodeDomNode.PropertyNode), $"{path}({PropertyNode.GetParamPreInfo(direction)})", csParam, description)); }
// 添加函数节点 public static CodeGenerateSystem.Controls.NodeListAttributeClass AddMethodNode(CodeGenerateSystem.Controls.NodesContainerControl.ContextMenuFilterData filterData, System.Reflection.MethodInfo methodInfo, Type parentClassType, CodeGenerateSystem.Controls.NodeListControl hostNodesList, EngineNS.ECSType csType, string attributeName, CodeDomNode.MethodInfoAssist.enHostType hostType) { //"CSUtility.Event.Attribute.AllowMember" // CodeGenerateSystem.Controls.NodeListAttributeClass attribute = null; var att = EngineNS.Rtti.AttributeHelper.GetCustomAttribute(methodInfo, attributeName, true); if (att == null) { return(attribute); } var path = EngineNS.Rtti.AttributeHelper.GetCustomAttributePropertyValue(att, "Path")?.ToString(); if (string.IsNullOrEmpty(path)) { path = EngineNS.Rtti.RttiHelper.GetAppTypeString(methodInfo.ReflectedType) + "." + methodInfo.Name; } var description = EngineNS.Rtti.AttributeHelper.GetCustomAttributePropertyValue(att, "Description").ToString(); //var refTypeStr = EngineNS.Rtti.RttiHelper.GetAppTypeString(methodInfo.ReflectedType); //var methodInfoString = GetParamFromMethodInfo(methodInfo, path); //methodInfoString += "," + csType.ToString() + "," + methodInfo.IsGenericMethodDefinition; //if (usefulMemberData != null) //{ // var usefulMemberStr = usefulMemberData.ToString().Replace(usefulMemberData.ClassTypeFullName, refTypeStr); // methodInfoString += ";" + usefulMemberStr; // if (!string.IsNullOrEmpty(usefulMemberData.MemberHostName)) // { // path = usefulMemberData.MemberHostName + "." + path; // } // if (usefulMemberData.HostControl != null) // { // path = GetNodeName(usefulMemberData) + "." + path; // } //} //path += "(" + refTypeStr + ")"; var csParam = new CodeDomNode.MethodInvokeNode.MethodNodeConstructionParams() { CSType = csType, ConstructParam = "", MethodInfo = GetMethodInfoAssistFromMethodInfo(methodInfo, parentClassType, hostType, path), }; var displayatt = methodInfo.GetCustomAttributes(typeof(EngineNS.Editor.DisplayParamNameAttribute), true); if (displayatt.Length > 0) { csParam.DisplayName = ((EngineNS.Editor.DisplayParamNameAttribute)displayatt[0]).DisplayName; } var attrs = methodInfo.GetCustomAttributes(typeof(EngineNS.Editor.MacrossPanelPathAttribute), true); if (attrs.Length == 0) { path = path.Replace('.', '/'); } else { path = ((EngineNS.Editor.MacrossPanelPathAttribute)attrs[0]).Path; } attribute = hostNodesList.AddNodesFromType(filterData, typeof(CodeDomNode.MethodInvokeNode), path, csParam, description, "", hostNodesList.TryFindResource("Icon_Function") as ImageSource); return(attribute); }