コード例 #1
0
 public MXNavigation(string pattern, CompactWebServer.HttpMethod method, MethodInfo methodinfo, Dictionary <string, string> parameters)
 {
     Method      = method;
     _methodInfo = methodinfo;
     Pattern     = pattern;
     Parameters  = parameters;
     Parts       = Segment.Split(Pattern);
 }
コード例 #2
0
        /// <summary>
        /// Returns a <see cref="MXNavigation"/> from the Navigation List that matches the specified URL.
        /// </summary>
        /// <param name="url">A <see cref="String"/> representing the URL to match.</param>
        /// <returns>A <see cref="MXNavigation"/> that matches the URL.</returns>
        public virtual MXNavigation MatchUrl(CompactWebServer.HttpMethod method, string url)
        {
            MXNavigation match = null;

            if (url == string.Empty)
            {
                // figure out what empty matches
                throw new NotImplementedException();
            }
            else
            {
                string[] urlPieces = url.Split('/');

                // first get the mappings with the same number of pieces, then march down one at a time, skipping those with parameters mappings (e.g., '{')
                foreach (var navEntry in this)
                {
                    if (navEntry.Method != CompactWebServer.HttpMethod.ANY && navEntry.Method != method)
                    {
                        continue;
                    }
                    if (navEntry.Parts.Length != urlPieces.Length)
                    {
                        continue;
                    }
                    int pieceNumber = 0;
                    for (; pieceNumber < urlPieces.Length; pieceNumber++)
                    {
                        if (!navEntry.Parts[pieceNumber].IsParameter && urlPieces[pieceNumber] != navEntry.Parts[pieceNumber].SegmentValue)
                        {
                            // skip parameter match fields
                            break;
                        }
                    }
                    if (pieceNumber == urlPieces.Length)
                    {
                        // all NON-parameters matched, found!
                        match = navEntry;
                        break;
                    }
                }
            }

            return(match);
        }
コード例 #3
0
        /// <summary>
        /// Adds the specified controller to the navigation list with the specified string pattern.
        /// </summary>
        /// <param name="pattern">The navigation pattern to associate with the controller.</param>
        /// <param name="controller">The controller to add to the navigation list.</param>
        /// <param name="parameters">Any default parameters to include when the controller is loaded.</param>
        public void Add(CompactWebServer.HttpMethod method, string pattern, MethodInfo methodinfo, Dictionary <string, string> parameters)
        {
            var mxNavItem = new MXNavigation(pattern, method, methodinfo, parameters);

            InternalAdd(mxNavItem);
        }