TunnelVisionLabs.Net.UriTemplate/UriTemplatePart.cs
/// <summary>
/// Build a regular expression pattern which matches this template part in a URI.
/// </summary>
/// <remarks>
/// <para>This method delegates the construction of the actual pattern building operation to
/// <see cref="BuildPatternBody"/>. The results of that call are then wrapped in a regular
/// expression named capture group.</para>
/// </remarks>
/// <param name="pattern">The <see cref="StringBuilder"/> to append the pattern to.</param>
/// <param name="groupName">The name to use for the named capture in the regular expression matching this template part.</param>
/// <param name="requiredVariables">A collection of variables which must be provided during the expansion process for the resulting URI to be valid.</param>
/// <param name="arrayVariables">A collection of variables to treat as associative arrays when matching a candidate URI to the template.</param>
/// <param name="mapVariables">A collection of variables to treat as associative maps when matching a candidate URI to the template.</param>
/// <exception cref="ArgumentException">
/// <para>If <paramref name="pattern"/> is <see langword="null"/>.</para>
/// <para>-or-</para>
/// <para>If <paramref name="groupName"/> is <see langword="null"/>.</para>
/// <para>-or-</para>
/// <para>If <paramref name="requiredVariables"/> is <see langword="null"/>.</para>
/// <para>-or-</para>
/// <para>If <paramref name="arrayVariables"/> is <see langword="null"/>.</para>
/// <para>-or-</para>
/// <para>If <paramref name="mapVariables"/> is <see langword="null"/>.</para>
/// </exception>
/// <exception cref="ArgumentException">
/// <para>If <paramref name="groupName"/> is empty.</para>
/// </exception>
Build a regular expression pattern which matches this template part in a URI.
Build a regular expression pattern which matches this template part in a URI .
public void BuildPattern(StringBuilder pattern, string groupName, ICollection<string> requiredVariables, ICollection<string> arrayVariables, ICollection<string> mapVariables)
        {
            if (pattern == null)
                throw new ArgumentNullException("pattern");
            if (groupName == null)
                throw new ArgumentNullException("groupName");
            if (requiredVariables == null)
                throw new ArgumentNullException("requiredVariables");
            if (arrayVariables == null)
                throw new ArgumentNullException("arrayVariables");
            if (mapVariables == null)
                throw new ArgumentNullException("mapVariables");
            if (string.IsNullOrEmpty(groupName))
                throw new ArgumentException("groupName cannot be empty");
            pattern.Append("(?<").Append(groupName).Append('>');
            BuildPatternBody(pattern, requiredVariables, arrayVariables, mapVariables);
            pattern.Append(')');
        }
public void BuildPattern ( StringBuilder pattern , string groupName , ICollection < string > requiredVariables , ICollection < string > arrayVariables , ICollection < string > mapVariables ) { if ( pattern == null ) throw new ArgumentNullException ( " " ) ; if ( groupName == null ) throw new ArgumentNullException ( " " ) ; if ( requiredVariables == null ) throw new ArgumentNullException ( " " ) ; if ( arrayVariables == null ) throw new ArgumentNullException ( " " ) ; if ( mapVariables == null ) throw new ArgumentNullException ( " " ) ; if ( string . IsNullOrEmpty ( groupName ) ) throw new ArgumentException ( " " ) ; pattern . Append ( " " ) . Append ( groupName ) . Append ( ' ' ) ; BuildPatternBody ( pattern , requiredVariables , arrayVariables , mapVariables ) ; pattern . Append ( ' ' ) ; }
Build a regular expression pattern which matches this template part in a URI.
Build a regular expression pattern which matches this template part in a URI .
None
If  is empty.
If is empty .
pattern
StringBuilder
The  to append the pattern to.
The to append the pattern to .
groupName
string
The name to use for the named capture in the regular expression matching this template part.
The name to use for the named capture in the regular expression matching this template part .
requiredVariables
ICollection<string>
A collection of variables which must be provided during the expansion process for the resulting URI to be valid.
A collection of variables which must be provided during the expansion process for the resulting URI to be valid .
arrayVariables
ICollection<string>
A collection of variables to treat as associative arrays when matching a candidate URI to the template.
A collection of variables to treat as associative arrays when matching a candidate URI to the template .
mapVariables
ICollection<string>
A collection of variables to treat as associative maps when matching a candidate URI to the template.
A collection of variables to treat as associative maps when matching a candidate URI to the template .
remarks
This method delegates the construction of the actual pattern building operation to
. The results of that call are then wrapped in a regular
expression named capture group.
This method delegates the construction of the actual pattern building operation to . The results of that call are then wrapped in a regular expression named capture group .