public Node ProcessElement(XElement startEl) { if (IsComplex(startEl)) { CompositeNode top = new CompositeNode(startEl.Name.LocalName); foreach (var attr in startEl.Attributes()) { var leaf = new LeafNode(typeof(String), attr.Name.LocalName, attr.Value); top.AddChildNode(leaf); } foreach (var childEl in startEl.Elements()) { var childNode = ProcessElement(childEl); top.AddChildNode(childNode); } return top; } else { LeafNode top = new LeafNode(typeof(String), "", ""); return top; } }
protected object ConvertLeafNode(Type desiredType, LeafNode lNode, out bool conversionSucceeded) { return Converter.Convert(desiredType, lNode.ValueType, lNode.Value, out conversionSucceeded); }
protected object ConvertLeafNode(Type desiredType, LeafNode lNode, out bool conversionSucceeded) { return(Converter.Convert(desiredType, lNode.ValueType, lNode.Value, out conversionSucceeded)); }
protected override MethodInfo SelectMethod(string action, IDictionary actions, IRequest request, IDictionary actionArgs) { if (String.Equals("collection", action, StringComparison.InvariantCultureIgnoreCase) || String.IsNullOrEmpty(action)) { switch(request.HttpMethod.ToUpper()) { case "GET": _controllerAction = "Index"; return (MethodInfo) actions["Index"]; case "POST": _controllerAction = "Create"; return (MethodInfo) actions["Create"]; default: return base.SelectMethod(action, actions, request, actionArgs); } } else { if (String.Equals("new", action, StringComparison.InvariantCultureIgnoreCase)) { _controllerAction = "New"; return (MethodInfo) actions["New"]; } if (!actions.Contains(action)) { MethodInfo selectedMethod; switch(request.HttpMethod.ToUpper()) { case "GET": _controllerAction = "Show"; selectedMethod = (MethodInfo) actions["Show"]; break; case "PUT": _controllerAction = "Update"; selectedMethod = (MethodInfo) actions["Update"]; break; case "DELETE": _controllerAction = "Destroy"; selectedMethod = (MethodInfo) actions["Destroy"]; break; default: //Should maybe just throw here. return base.SelectMethod(action, actions, request, actionArgs); } if (selectedMethod != null) { LeafNode n = new LeafNode(typeof(String), "ID", action); ParamsNode.AddChildNode(n); } return selectedMethod; } else { _controllerAction = action; return base.SelectMethod(action, actions, request, actionArgs); } } }