Example #1
0
        static void Main(string[] args)
        {
            var docs = new XMLDocs();

            docs.ProcessXML("_source\\EasyHosting.xml");
            docs.WriteToFiles();

            var docs2 = new XMLDocs();

            docs2.ProcessXML("_source\\ServerSocket.xml");
            docs2.WriteToFiles();
        }
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Method"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 10, false, false, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, false, menu);
                    if (typeof(UnityEngine.Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 10, false, false, menu);
                    }
                }
                menu.ShowAsBrowser("Select Method", this.GetType());
                Event.current.Use();
            }


            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Method", targetMethod.Name);
                UnityEditor.EditorGUILayout.LabelField("Returns", targetMethod.ReturnType.FriendlyName());
                UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetMethod), UnityEditor.MessageType.None);

                if (targetMethod.ReturnType == typeof(IEnumerator))
                {
                    GUILayout.Label("<b>This will execute as a Coroutine!</b>");
                }

                GUILayout.EndVertical();

                var paramNames = targetMethod.GetParameters().Select(p => p.Name.SplitCamelCase()).ToArray();
                for (var i = 0; i < paramNames.Length; i++)
                {
                    NodeCanvas.Editor.BBParameterEditor.ParameterField(paramNames[i], parameters[i]);
                }

                if (targetMethod.ReturnType != typeof(void) && targetMethod.ReturnType != typeof(IEnumerator))
                {
                    NodeCanvas.Editor.BBParameterEditor.ParameterField("Save Return Value", returnValue, true);
                }
            }
        }
Example #3
0
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Field"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetInstanceFieldSelectionMenu(comp.GetType(), typeof(object), SetTargetField, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticFieldSelectionMenu(t, typeof(object), SetTargetField, menu);
                    if (typeof(Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceFieldSelectionMenu(t, typeof(object), SetTargetField, menu);
                    }
                }
                menu.ShowAsBrowser("Select Field", this.GetType());
                Event.current.Use();
            }

            if (targetField != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", targetField.RTReflectedOrDeclaredType().FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Field", targetField.Name);
                UnityEditor.EditorGUILayout.LabelField("Field Type", targetField.FieldType.FriendlyName());
                UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetField), UnityEditor.MessageType.None);
                GUILayout.EndVertical();

                GUI.enabled = checkValue.varType == typeof(float) || checkValue.varType == typeof(int);
                comparison  = (CompareMethod)UnityEditor.EditorGUILayout.EnumPopup("Comparison", comparison);
                GUI.enabled = true;
                NodeCanvas.Editor.BBParameterEditor.ParameterField("Value", checkValue);
            }
        }
        ///----------------------------------------------------------------------------------------------
        ///---------------------------------------UNITY EDITOR-------------------------------------------
#if UNITY_EDITOR
        protected override void OnTaskInspectorGUI()
        {
            if (!Application.isPlaying && GUILayout.Button("Select Property"))
            {
                var menu = new UnityEditor.GenericMenu();
                if (agent != null)
                {
                    foreach (var comp in agent.GetComponents(typeof(Component)).Where(c => c.hideFlags != HideFlags.HideInInspector))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(comp.GetType(), typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    }
                    menu.AddSeparator("/");
                }
                foreach (var t in TypePrefs.GetPreferedTypesList(typeof(object)))
                {
                    menu = EditorUtils.GetStaticMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    if (typeof(UnityEngine.Component).IsAssignableFrom(t))
                    {
                        menu = EditorUtils.GetInstanceMethodSelectionMenu(t, typeof(object), typeof(object), SetMethod, 0, true, true, menu);
                    }
                }
                menu.ShowAsBrowser("Select Property", this.GetType());
                Event.current.Use();
            }

            if (targetMethod != null)
            {
                GUILayout.BeginVertical("box");
                UnityEditor.EditorGUILayout.LabelField("Type", targetMethod.RTReflectedOrDeclaredType().FriendlyName());
                UnityEditor.EditorGUILayout.LabelField("Property", targetMethod.Name);
                UnityEditor.EditorGUILayout.LabelField("Property Type", targetMethod.ReturnType.FriendlyName());
                UnityEditor.EditorGUILayout.HelpBox(XMLDocs.GetMemberSummary(targetMethod), UnityEditor.MessageType.None);
                GUILayout.EndVertical();

                NodeCanvas.Editor.BBParameterEditor.ParameterField("Save As", returnValue, true);
            }
        }
Example #5
0
        public static ConstructorDef FromConstructorInfo(ClassDef parentClass, ConstructorInfo info, XMLDocs doc = null)
        {
            var def = new ConstructorDef(parentClass);

            def.ConstructorInfo = info;

            // Określanie poziomu dostępu
            if (info.IsPublic)
            {
                def.AccessType = AccessType.PUBLIC;
            }
            else if (info.IsFamily)
            {
                def.AccessType = AccessType.PROTECTED;
            }
            else if (info.IsPrivate)
            {
                def.AccessType = AccessType.PRIVATE;
            }
            else
            {
                def.AccessType = AccessType.INNER;
            }


            // Parametry
            var parameters = info.GetParameters();

            foreach (var param in parameters)
            {
                def.AddParam(ParamDef.FromParamInfo(param));
            }

            // Dopisywanie dokumentacji
            if (doc != null)
            {
                XmlNode docsNode = doc.GetDocumentation(def);

                if (docsNode != null)
                {
                    XmlNode current;
                    for (int i = 0; i < docsNode.ChildNodes.Count; i++)
                    {
                        current = docsNode.ChildNodes[i];

                        switch (current.Name)
                        {
                        case "summary":
                            def.Summary = current.InnerText.Replace("\n\r            ", "\n").Replace("\r\n            ", "\n").Replace("\n            ", "\n");
                            def.Summary = def.Summary.Substring(1, def.Summary.Length - 2);
                            def.Summary.Replace("\n", "\n\t");
                            break;

                        case "remarks":
                            def.Remarks = current.InnerText;
                            break;

                        case "param":
                            string name  = current.Attributes["name"].InnerText;
                            var    param = def.GetParam(name);
                            if (param != null)
                            {
                                param.Description = current.InnerText;
                            }
                            else
                            {
                                Console.WriteLine("Parameter not found: " + name);
                            }
                            break;

                        default:
                            Console.WriteLine("Unrecognized tag " + current.Name + " in class definition of " + def.ParentClass.TypeDef.FullName + ", method name " + def.Name);
                            break;
                        }
                    }
                }
            }

            return(def);
        }
Example #6
0
        public static ClassDef FromType(Type type, XMLDocs doc = null)
        {
            if (type == typeof(ActionsManager))
            {
                Console.WriteLine("OK");
            }

            var def = new ClassDef();

            def.TypeDef = new TypeDef(type);

            if (type.BaseType != null)
            {
                def.BaseClass = new TypeDef(type.BaseType);
            }

            // Określenie typu dostępu
            if (type.IsPublic)
            {
                def.AccessType = AccessType.PUBLIC;
            }
            else if (type.IsNestedPublic)
            {
                def.AccessType = AccessType.PUBLIC;
                def.Nested     = true;
            }
            else if (type.IsNestedFamily)
            {
                def.AccessType = AccessType.PROTECTED;
                def.Nested     = true;
            }
            else if (type.IsNestedPrivate)
            {
                def.AccessType = AccessType.PRIVATE;
                def.Nested     = true;
            }
            else
            {
                def.AccessType = AccessType.INNER;
            }

            // Sczytywanie metod klasy
            var methods      = type.GetMethods(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly | BindingFlags.Static);
            var constructors = type.GetConstructors(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
            var properties   = type.GetProperties(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
            var events       = type.GetEvents(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);
            var fields       = type.GetFields(BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static);

            MethodDef mdef;

            foreach (var method in methods)
            {
                mdef = MethodDef.FromMethodInfo(def, method, doc);
                def.Methods.Add(method, mdef);
            }
            ConstructorDef cdef;

            foreach (var constr in constructors)
            {
                cdef = ConstructorDef.FromConstructorInfo(def, constr, doc);
                def.Constructors.Add(constr, cdef);
            }
            PropertyDef pdef;

            foreach (var prpt in properties)
            {
                pdef = PropertyDef.FromPropertyInfo(def, prpt, doc);
                def.Properties.Add(prpt, pdef);
            }
            EventDef edef;

            foreach (var evt in events)
            {
                edef = EventDef.FromEventInfo(def, evt, doc);
                def.Events.Add(evt, edef);
            }
            FieldDef fdef;

            foreach (var fld in fields)
            {
                if (!fld.Name.Contains("k__BackingField"))
                {
                    fdef = FieldDef.FromFieldInfo(def, fld, doc);
                    def.Fields.Add(fld, fdef);
                }
            }

            if (doc != null)
            {
                XmlNode docsNode = doc.GetDocumentation(type);

                if (docsNode != null)
                {
                    XmlNode current;
                    for (int i = 0; i < docsNode.ChildNodes.Count; i++)
                    {
                        current = docsNode.ChildNodes[i];

                        switch (current.Name)
                        {
                        case "summary":
                            def.Summary = current.InnerText.Replace("\n\r            ", "\n").Replace("\r\n            ", "\n").Replace("\n            ", "\n");
                            def.Summary = def.Summary.Substring(1, def.Summary.Length - 2);
                            def.Summary.Replace("\n", "\n\t");
                            break;

                        case "remarks":
                            def.Remarks = current.InnerText;
                            break;

                        default:
                            Console.WriteLine("Unrecognized tag " + current.Name + " in class definition of " + def.TypeDef.FullName);
                            break;
                        }
                    }
                }
            }

            return(def);
        }
Example #7
0
        public static EventDef FromEventInfo(ClassDef parentClass, EventInfo info, XMLDocs doc = null)
        {
            var def = new EventDef();

            def.ParentClass         = parentClass;
            def.EventHandlerTypeDef = new TypeDef(info.EventHandlerType);
            def.Name = info.Name;
            var addMethod = info.GetAddMethod(true);

            def.IsStatic = addMethod.IsStatic;

            // Określanie poziomu dostępu
            if (addMethod.IsPublic)
            {
                def.AccessType = AccessType.PUBLIC;
            }
            else if (addMethod.IsFamily)
            {
                def.AccessType = AccessType.PROTECTED;
            }
            else if (addMethod.IsPrivate)
            {
                def.AccessType = AccessType.PRIVATE;
            }
            else
            {
                def.AccessType = AccessType.INNER;
            }

            if (doc != null)
            {
                XmlNode docsNode = doc.GetDocumentation(info);

                if (docsNode != null)
                {
                    XmlNode current;
                    for (int i = 0; i < docsNode.ChildNodes.Count; i++)
                    {
                        current = docsNode.ChildNodes[i];

                        switch (current.Name)
                        {
                        case "summary":
                            def.Summary = current.InnerText.Replace("\n\r            ", "\n").Replace("\r\n            ", "\n").Replace("\n            ", "\n");
                            def.Summary = def.Summary.Substring(1, def.Summary.Length - 2);
                            def.Summary.Replace("\n", "\n\t");
                            break;

                        case "remarks":
                            def.Remarks = current.InnerText;
                            break;

                        default:
                            Console.WriteLine("Unrecognized tag " + current.Name + " in class definition of " + def.ParentClass.TypeDef.FullName + ", event name " + def.Name);
                            break;
                        }
                    }
                }
            }

            return(def);
        }