예제 #1
0
        public static void SendScriptParameters(Client client, string ClassName, string MethodName, int overload)
        {
            TcpPacket   packet  = new TcpPacket("scriptparam");
            string      tempStr = "";
            EditorClass @class  = classes.FindByName(ClassName);

            if (@class != null)
            {
                int slot = @class.FindMethodByName(MethodName.Trim().Replace("[static] ", ""));
                if (slot > -1)
                {
                    if (overload - 1 > @class.Methods[slot].Params.Count)
                    {
                        overload = 1;
                    }
                    tempStr = @class.Methods[slot].Params[overload - 1].ParamString;
                    if (!string.IsNullOrEmpty(@class.Methods[slot].Params[overload - 1].ReturnVal))
                    {
                        tempStr += "\n" + @class.Methods[slot].Params[overload - 1].ReturnVal;
                    }
                }
            }
            packet.AppendParameter(tempStr);
            Messenger.SendDataTo(client, packet);
        }
예제 #2
0
        public static void SendScriptMethods(Client client, string ClassName)
        {
            TcpPacket   packet = new TcpPacket("scriptmethods");
            EditorClass @class = classes.FindByName(ClassName);

            if (@class != null)
            {
                packet.AppendParameters(@class.Methods.Count.ToString(), ClassName);
                for (int i = 0; i < @class.Methods.Count; i++)
                {
                    packet.StartParameterSegment();
                    if (@class.Methods[i].Static)
                    {
                        packet.AppendParameterSegment("[static] ");
                    }
                    if (!string.IsNullOrEmpty(@class.Methods[i].Type))
                    {
                        packet.AppendParameterSegment(@class.Methods[i].Type);
                        packet.AppendParameterSegment(" ");
                    }
                    packet.AppendParameterSegment(@class.Methods[i].Name);
                    packet.EndParameterSegment();
                }
                packet.FinalizePacket();
                Messenger.SendDataTo(client, packet);
            }
        }
예제 #3
0
 private void LoadClassMethods(Type type)
 {
     EditorClass editorClass = new EditorClass();
     editorClass.Name = type.FullName;
     foreach (MethodInfo method in type.GetMethods()) {
         if (method.IsPublic && !method.Name.StartsWith("add_") && !method.Name.StartsWith("remove_")) {
             string methodName = method.Name.TrimStart("get_".ToCharArray()).TrimStart("set_".ToCharArray());
             EditorMethod editorMethod;
             int slot = editorClass.FindMethodByName(methodName);
             if (slot > -1) {
                 editorMethod = editorClass.Methods[slot];
             } else {
                 editorMethod = new EditorMethod();
                 editorMethod.Name = methodName;
             }
             editorMethod.Static = method.IsStatic;
             if (slot == -1) {
                 if (method.Name.StartsWith("get_")) {
                     editorMethod.Type = "[prop-get]";
                 } else if (method.Name.StartsWith("set_")) {
                     editorMethod.Type = "[prop-set]";
                 }
             } else {
                 if (method.Name.StartsWith("get_")) {
                     if (editorMethod.Type == "[prop-get]") {
                         editorMethod.Type = "[prop-get]";
                     } else if (editorMethod.Type == "[prop-set]") {
                         editorMethod.Type = "[prop-get/set]";
                     }
                 } else if (method.Name.StartsWith("set_")) {
                     if (editorMethod.Type == "[prop-set]") {
                         editorMethod.Type = "[prop-set]";
                     } else if (editorMethod.Type == "[prop-get]") {
                         editorMethod.Type = "[prop-get/set]";
                     }
                 }
             }
             if (!string.IsNullOrEmpty(editorMethod.Type) && editorMethod.Type.StartsWith("[prop")) {
                 if (editorMethod.Params.Count == 0) {
                     ParamSet param = new ParamSet();
                     param.ParamString = "No parameters";
                     editorMethod.Params.Add(param);
                 }
             } else {
                 LoadMethodParameters(method, editorMethod);
             }
             if (slot == -1) {
                 editorClass.Methods.Add(editorMethod);
             }
         }
     }
     editorClass.Methods.Sort(delegate(EditorMethod m1, EditorMethod m2) { return m1.Name.CompareTo(m2.Name); });
     classes.Add(editorClass);
 }
예제 #4
0
        private void LoadClassMethods(Type type)
        {
            EditorClass editorClass = new EditorClass();

            editorClass.Name = type.FullName;
            foreach (MethodInfo method in type.GetMethods())
            {
                if (method.IsPublic && !method.Name.StartsWith("add_") && !method.Name.StartsWith("remove_"))
                {
                    string       methodName = method.Name.TrimStart("get_".ToCharArray()).TrimStart("set_".ToCharArray());
                    EditorMethod editorMethod;
                    int          slot = editorClass.FindMethodByName(methodName);
                    if (slot > -1)
                    {
                        editorMethod = editorClass.Methods[slot];
                    }
                    else
                    {
                        editorMethod      = new EditorMethod();
                        editorMethod.Name = methodName;
                    }
                    editorMethod.Static = method.IsStatic;
                    if (slot == -1)
                    {
                        if (method.Name.StartsWith("get_"))
                        {
                            editorMethod.Type = "[prop-get]";
                        }
                        else if (method.Name.StartsWith("set_"))
                        {
                            editorMethod.Type = "[prop-set]";
                        }
                    }
                    else
                    {
                        if (method.Name.StartsWith("get_"))
                        {
                            if (editorMethod.Type == "[prop-get]")
                            {
                                editorMethod.Type = "[prop-get]";
                            }
                            else if (editorMethod.Type == "[prop-set]")
                            {
                                editorMethod.Type = "[prop-get/set]";
                            }
                        }
                        else if (method.Name.StartsWith("set_"))
                        {
                            if (editorMethod.Type == "[prop-set]")
                            {
                                editorMethod.Type = "[prop-set]";
                            }
                            else if (editorMethod.Type == "[prop-get]")
                            {
                                editorMethod.Type = "[prop-get/set]";
                            }
                        }
                    }
                    if (!string.IsNullOrEmpty(editorMethod.Type) && editorMethod.Type.StartsWith("[prop"))
                    {
                        if (editorMethod.Params.Count == 0)
                        {
                            ParamSet param = new ParamSet();
                            param.ParamString = "No parameters";
                            editorMethod.Params.Add(param);
                        }
                    }
                    else
                    {
                        LoadMethodParameters(method, editorMethod);
                    }
                    if (slot == -1)
                    {
                        editorClass.Methods.Add(editorMethod);
                    }
                }
            }
            editorClass.Methods.Sort(delegate(EditorMethod m1, EditorMethod m2) { return(m1.Name.CompareTo(m2.Name)); });
            classes.Add(editorClass);
        }