/// <summary> /// Initializes a new instance of the <see cref="ApiNode"/> class. /// </summary> /// <param name="parent">The parent.</param> /// <param name="path">The path.</param> /// <param name="dtoType">Type of the dto.</param> /// <param name="parameterName">Name of the parameter.</param> public ApiNode(ApiNode parent, string path, Type dtoType, string parameterName, string parentParameterName) { this.Parent = parent; this.Path = path; this.DtoType = dtoType; this.ParameterName = parameterName; this.ParentParameterName = parentParameterName; this.Sons = new Dictionary<string, ApiNode>(); }
/// <summary> /// Configures the API from a child node. /// </summary> /// <param name="node">The node.</param> /// <param name="apinode">The apinode.</param> private static void ConfigureApi(XmlNode node, ApiNode apinode) { NodeAttributes attributes = new NodeAttributes(node); Type dtoType = GetDtoType(attributes.AsString("dtoType"), attributes.AsString("dtoName"), attributes.AsString("path"), attributes.AsString("entityName"), attributes.AsString("entityType")); if (dtoType != null) { string parameterName = attributes.AsString("parameterName"); if (string.IsNullOrEmpty(parameterName)) { parameterName = GetParameterName(attributes.AsString("path"), dtoType); } ApiNode childnode = apinode.AddNode(attributes.AsString("path"), dtoType, parameterName, attributes.AsString("byparent")); foreach (XmlNode subnode in node.SelectNodes("api")) { ConfigureApi(subnode, childnode); } } }
/// <summary> /// Adds the specified path. /// </summary> /// <param name="path">The path.</param> /// <param name="dtoType">Type of the dto.</param> /// <param name="parameterName">Name of the parameter.</param> /// <returns></returns> public ApiNode AddNode(string path, Type dtoType, string parameterName, string parentParameterName) { ApiNode result = new ApiNode(this, path, dtoType, parameterName, parentParameterName); this.Sons.Add(result.Path.ToLower(), result); return result; }