예제 #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);
                }
            }
        }
예제 #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));
 }
예제 #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);
         }
     }
 }
예제 #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);
 }