コード例 #1
0
        /// <summary>Tries to create a key segment for the given filter if it is non empty.</summary>
        /// <param name="previous">Segment on which to compose.</param>
        /// <param name="filter">Filter portion of segment, possibly null.</param>
        /// <param name="keySegment">The key segment that was created if the key was non-empty.</param>
        /// <returns>Whether the key was non-empty.</returns>
        internal static bool TryCreateKeySegmentFromParentheses(IPathSegment previous, string filter, out IPathSegment keySegment)
        {
            DebugUtils.CheckNoExternalCallers();
            Debug.Assert(filter != null, "filter != null");
            Debug.Assert(previous != null, "segment!= null");

            WebUtil.CheckSyntaxValid(!previous.SingleResult);

            KeyInstance key;

            WebUtil.CheckSyntaxValid(KeyInstance.TryParseKeysFromUri(filter, out key));

            if (key.IsEmpty)
            {
                keySegment = null;
                return(false);
            }

            keySegment = CreateKeySegment(previous, key);
            return(true);
        }