Exemplo n.º 1
0
 private static CodeGenerateSystem.Controls.NodeListAttributeClass GetNodeListAttClassRoot(CodeGenerateSystem.Controls.NodeListAttributeClass attClass)
 {
     if (attClass == null)
     {
         return(null);
     }
     if (attClass.Parent == null)
     {
         return(attClass);
     }
     return(GetNodeListAttClassRoot(attClass.Parent));
 }
Exemplo n.º 2
0
        // 添加函数节点
        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);
        }