private List <string> ListActions(string controllerMappingFileName) { StreamReader stream = null; List <string> result = new List <string>(); try { stream = new StreamReader( Directory.GetCurrentDirectory() + $@"\Mappings\{controllerMappingFileName}", Encoding.UTF8); XmlDocument xml = new XmlDocument(); xml.Load(stream); stream.Close(); XmlNode node = new TypedObjectsRequestManager().FindNode(xml.ChildNodes, "ControllerMapping"); foreach (XmlNode chNode in node.ChildNodes) { if (chNode.Name.Equals("RequestMapping")) { foreach (XmlAttribute a in chNode.Attributes) { result.Add(a.Value); } } } return(result); } catch (Exception ex) { return(new List <string>()); } }
private ControllerInfo GetControllerInfo(string mappingName) { StreamReader stream = null; try { stream = new StreamReader( Directory.GetCurrentDirectory() + $@"\Mappings\{mappingName}", Encoding.UTF8); XmlDocument xml = new XmlDocument(); xml.Load(stream); stream.Close(); ControllerInfo info = new ControllerInfo(); info.ControllerName = mappingName.Replace(".xml", string.Empty); info.ControllerActions = ListActions(mappingName); XmlNode node = new TypedObjectsRequestManager().FindNode(xml.ChildNodes, "ControllerMapping"); foreach (XmlAttribute attr in node.Attributes) { if (attr.Name.Equals("class")) { info.ControllerClass = attr.Value; } } return(info); } catch (Exception ex) { return(null); } }