Esempio n. 1
0
        private void SetRoutes(XmlDocument xmlDoc)
        {
            XmlNode rootNode = xmlDoc.SelectSingleNode("config/route-list");

            if (rootNode == null)
            {
                return;
            }
            _routePyDict.Clear();
            XmlNodeList childList = rootNode.SelectNodes("route");

            if (childList == null)
            {
                return;
            }
            foreach (XmlElement routeElement in childList)
            {
                int    actionId        = routeElement.GetAttribute("action").ToInt();
                string routePath       = routeElement.GetAttribute("path");
                string typeName        = routeElement.GetAttribute("type");
                bool   ignoreAuthorize = routeElement.GetAttribute("ignoreAuthorize").ToBool();
                if (!string.IsNullOrEmpty(routePath))
                {
                    RouteItem routeItem = new RouteItem()
                    {
                        ActionId        = actionId,
                        ScriptPath      = FormatPythonPath(routePath),
                        TypeName        = typeName,
                        IgnoreAuthorize = ignoreAuthorize
                    };
                    if (!_routePyDict.ContainsKey(actionId))
                    {
                        _routePyDict.TryAdd(actionId, routeItem);
                    }
                }
                else
                {
                    TraceLog.WriteError("Python route actionId:{0} path: is empyt.", actionId);
                }
            }
        }
Esempio n. 2
0
 /// <summary>
 /// 尝试获取Action
 /// </summary>
 /// <param name="actionId"></param>
 /// <param name="routeItem"></param>
 /// <returns></returns>
 public bool TryGetAction(int actionId, out RouteItem routeItem)
 {
     return(_routePyDict.TryGetValue(actionId, out routeItem));
 }
Esempio n. 3
0
 private void SetRoutes(XmlDocument xmlDoc)
 {
     XmlNode rootNode = xmlDoc.SelectSingleNode("config/route-list");
     if (rootNode == null)
     {
         return;
     }
     _routePyDict.Clear();
     XmlNodeList childList = rootNode.SelectNodes("route");
     if (childList == null)
     {
         return;
     }
     foreach (XmlElement routeElement in childList)
     {
         int actionId = routeElement.GetAttribute("action").ToInt();
         string routePath = routeElement.GetAttribute("path");
         string typeName = routeElement.GetAttribute("type");
         bool ignoreAuthorize = routeElement.GetAttribute("ignoreAuthorize").ToBool();
         if (!string.IsNullOrEmpty(routePath))
         {
             RouteItem routeItem = new RouteItem()
             {
                 ActionId = actionId,
                 ScriptPath = FormatPythonPath(routePath),
                 TypeName = typeName,
                 IgnoreAuthorize = ignoreAuthorize
             };
             if (!_routePyDict.ContainsKey(actionId))
             {
                 _routePyDict.TryAdd(actionId, routeItem);
             }
         }
         else
         {
             TraceLog.WriteError("Python route actionId:{0} path: is empyt.", actionId);
         }
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 尝试获取Action
 /// </summary>
 /// <param name="actionId"></param>
 /// <param name="routeItem"></param>
 /// <returns></returns>
 public bool TryGetAction(int actionId, out RouteItem routeItem)
 {
     return _routePyDict.TryGetValue(actionId, out routeItem);
 }