src/Azos.Wave/URIPattern.cs
/// <summary>
/// Creates URI from the supplied values for this pattern
/// </summary>
Creates URI from the supplied values for this pattern
Creates URI from the supplied values for this pattern
public Uri MakeURI(IDictionary<string, object> values, Uri prefix = null)
    {
      var result = new StringBuilder();
      var portion = chunkPortion.Path;
      foreach(var chunk in m_Chunks)
      {
        if (chunk.IsPathDiv)
        {
          result.Append("/");
          continue;
        }
        if (portion!=chunk.Portion)
        {
          portion = chunk.Portion;
          result.Append('?');
        }
        if (chunk.IsVar)
        {
          object value;
          if (!values.TryGetValue(chunk.Name, out value) || value==null)
          {
            value = chunk.DefaultValue;
            if (value==null) continue;
          }
          result.Append(value.ToString());
          continue;
        }
        result.Append( chunk.Portion==chunkPortion.Query ? Uri.EscapeDataString(chunk.Name) : chunk.Name);
      }
      return prefix!=null ? new Uri(prefix, result.ToString()) :
                            new Uri(result.ToString(), UriKind.RelativeOrAbsolute);
    }
public Uri MakeURI ( IDictionary < string , object > values , Uri prefix = null ) { var result = new StringBuilder ( ) ; var portion = chunkPortion . Path ; foreach ( var chunk in m_Chunks ) { if ( chunk . IsPathDiv ) { result . Append ( " " ) ; continue ; } if ( portion != chunk . Portion ) { portion = chunk . Portion ; result . Append ( ' ' ) ; } if ( chunk . IsVar ) { object value ; if ( ! values . TryGetValue ( chunk . Name , out value ) || value == null ) { value = chunk . DefaultValue ; if ( value == null ) continue ; } result . Append ( value . ToString ( ) ) ; continue ; } result . Append ( chunk . Portion == chunkPortion . Query ? Uri . EscapeDataString ( chunk . Name ) : chunk . Name ) ; } return prefix != null ? new Uri ( prefix , result . ToString ( ) ) : new Uri ( result . ToString ( ) , UriKind . RelativeOrAbsolute ) ; }
Creates URI from the supplied values for this pattern
Creates URI from the supplied values for this pattern
values
IDictionary<string, object>
prefix
Uri