예제 #1
0
        private static void loadExtraMeta(string xmlFilename)
        {
            try
            {
                extraPropertyDict.Clear();

                XmlDocument xmlDoc = new XmlDocument();
                Encoding utf8WithoutBom = new UTF8Encoding(false);
                using (StreamReader fileStream = new StreamReader(xmlFilename, utf8WithoutBom))
                {
                    xmlDoc.Load(fileStream);
                }

                XmlNode rootNode = xmlDoc.DocumentElement;

                if (rootNode.Name == "extrameta")
                {
                    foreach (XmlNode typeNode in rootNode.ChildNodes)
                    {
                        if (typeNode.Name == "agents")
                        {
                            foreach (XmlNode xmlNode in typeNode.ChildNodes)
                            {
                                if (xmlNode.Name == "agent")
                                {
                                    string agentName = GetAttribute(xmlNode, "classfullname");

                                    foreach (XmlNode bbNode in xmlNode)
                                    {
                                        if (bbNode.Name == "properties")
                                        {
                                            foreach (XmlNode propNode in bbNode)
                                            {
                                                if (propNode.Name == "property")
                                                {
                                                    string propName = GetAttribute(propNode, "name");
                                                    string propType = GetAttribute(propNode, "type");

                                                    extraPropertyDict[agentName + "::" + propName] = propType;
                                                }
                                            }
                                        }
                                        else if (bbNode.Name == "methods")
                                        {
                                            foreach (XmlNode methodNode in bbNode)
                                            {
                                                if (methodNode.Name == "method")
                                                {
                                                    Method method = new Method();

                                                    method.Name = GetAttribute(methodNode, "name");
                                                    method.ReturnType = GetAttribute(methodNode, "returntype");

                                                    foreach (XmlNode paramNode in methodNode)
                                                    {
                                                        Method.Param param = new Method.Param();

                                                        param.Name = GetAttribute(paramNode, "name");
                                                        param.Type = GetAttribute(paramNode, "type");
                                                        param.IsOut = GetAttribute(paramNode, "isout");
                                                        param.IsRef = GetAttribute(paramNode, "isref");

                                                        if (string.IsNullOrEmpty(param.IsOut))
                                                            param.IsOut = "false";

                                                        if (string.IsNullOrEmpty(param.IsRef))
                                                            param.IsRef = "false";

                                                        method.Params.Add(param);
                                                    }

                                                    extraMethodDict[agentName + "::" + method.Name] = method;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }
예제 #2
0
        private static void loadExtraMeta(string xmlFilename)
        {
            try
            {
                extraPropertyDict.Clear();

                XmlDocument xmlDoc         = new XmlDocument();
                Encoding    utf8WithoutBom = new UTF8Encoding(false);
                using (StreamReader fileStream = new StreamReader(xmlFilename, utf8WithoutBom))
                {
                    xmlDoc.Load(fileStream);
                }

                XmlNode rootNode = xmlDoc.DocumentElement;

                if (rootNode.Name == "extrameta")
                {
                    foreach (XmlNode typeNode in rootNode.ChildNodes)
                    {
                        if (typeNode.Name == "agents")
                        {
                            foreach (XmlNode xmlNode in typeNode.ChildNodes)
                            {
                                if (xmlNode.Name == "agent")
                                {
                                    string agentName = GetAttribute(xmlNode, "classfullname");

                                    foreach (XmlNode bbNode in xmlNode)
                                    {
                                        if (bbNode.Name == "properties")
                                        {
                                            foreach (XmlNode propNode in bbNode)
                                            {
                                                if (propNode.Name == "property")
                                                {
                                                    string propName = GetAttribute(propNode, "name");
                                                    string propType = GetAttribute(propNode, "type");

                                                    extraPropertyDict[agentName + "::" + propName] = propType;
                                                }
                                            }
                                        }
                                        else if (bbNode.Name == "methods")
                                        {
                                            foreach (XmlNode methodNode in bbNode)
                                            {
                                                if (methodNode.Name == "method")
                                                {
                                                    Method method = new Method();

                                                    method.Name       = GetAttribute(methodNode, "name");
                                                    method.ReturnType = GetAttribute(methodNode, "returntype");

                                                    foreach (XmlNode paramNode in methodNode)
                                                    {
                                                        Method.Param param = new Method.Param();

                                                        param.Name  = GetAttribute(paramNode, "name");
                                                        param.Type  = GetAttribute(paramNode, "type");
                                                        param.IsOut = GetAttribute(paramNode, "isout");
                                                        param.IsRef = GetAttribute(paramNode, "isref");

                                                        if (string.IsNullOrEmpty(param.IsOut))
                                                        {
                                                            param.IsOut = "false";
                                                        }

                                                        if (string.IsNullOrEmpty(param.IsRef))
                                                        {
                                                            param.IsRef = "false";
                                                        }

                                                        method.Params.Add(param);
                                                    }

                                                    extraMethodDict[agentName + "::" + method.Name] = method;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch
            {
            }
        }