Esempio n. 1
0
 public RouteInvocation
     (Feature feature, IRouteTarget target, IDictionary <string, string> data)
 {
     this.Feature   = feature;
     this.Target    = target;
     this.RouteData = data;
 }
 public RouteInvocation
     (IFeature feature, IRouteTarget target, IDictionary<string, string> data)
 {
     this.Feature = feature;
     this.Target = target;
     this.RouteData = data;
 }
Esempio n. 3
0
        /// <summary>
        ///  Registers a route on this route table.
        /// </summary>
        /// <param name="specification">
        ///  The route specification. null or an empty string indicates the root
        ///  node.
        /// </param>
        /// <param name="target">
        ///  The route target.
        /// </param>
        /// <param name="constraint">
        ///  A predicate which allows us to add constraints to the route.
        /// </param>

        public void Add(string specification, IRouteTarget target)
        {
            var pathParts = specification.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
            var node      = Root;

            foreach (var name in pathParts)
            {
                node = node.GetOrCreateChild(name);
            }

            node.Targets.Add(target);

            // When an optional parameter is missing, the route invocation will
            // land on the parent node, which will not otherwise be assigned to
            // this route. Therefore in this case, back up the tree associating
            // this definition with all optional parameters and the last
            // required one.
            while (node is Parameter && ((Parameter)node).Optional &&
                   node.Parent != null)
            {
                node = node.Parent;
                node.Targets.Add(target);
            }
        }