Changes between Version 3 and Version 4 of WikiStart

Show
Ignore:
Timestamp:
01/27/14 11:34:27 (10 years ago)
Author:
smagi
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v3 v4  
    77 1. IContinuation for specifying page parameter types 
    88 1. Unsafe<T> for specifying unsafe/insecure page parameters 
    9  1. Continuation.ToUrl overloads for generating URLs from continuations + arguments 
    10  1. Continuation.TryParseX for parsing page parameters 
     9 1. {{{Continuation.ToUrl}}} overloads for generating URLs from continuations + arguments 
     10 1. {{{Continuation.TryParseX}}} for parsing page parameters 
    1111 
    1212== Typed Page Parameters == 
     
    6060              3.AsParam(), "hello world!".AsParam()); 
    6161}}} 
    62 The first type argument, SomePage, is the continuation type. The subsequent type arguments are the type arguments to IContinuation<...>. Another method of generating a URL that requires fewer type annotations: 
     62The first type argument, {{{SomePage}}}, is the continuation type. The subsequent type arguments are the type arguments to IContinuation<...>. Another method of generating a URL that requires fewer type annotations: 
    6363{{{ 
    6464var url = Continuation.Params(3.AsParam(), "hello world!".AsParam()); 
     
    7474                      .ToUrl<SomePage>(); 
    7575}}} 
     76 
     77== Parsing Page Parameters == 
     78 
     79Inside the continuation, you can obtain access to page parameter values via the {{{Param.TryParseX}}} overloads, where X is the index of the parameter in the IContinuation<...> specification: 
     80{{{ 
     81public class SomePage : System.Web.Page, IContinuation<int, string> 
     82{ 
     83  int arg0; 
     84  string arg1; 
     85 
     86  override protected void OnInit(EventArgs e) 
     87  { 
     88    if (this.TryParse0(out arg0)); //do something with arg0 
     89    if (this.TryParse1(out arg1)); //do something with arg1 
     90  } 
     91} 
     92}}} 
     93The above will only work if the types are IConvertible. For non-IConvertible values, you instead need to parse an Id<TKey, TType>: 
     94{{{ 
     95public class SomePage : System.Web.Page, IContinuation<Project, Customer> 
     96{ 
     97  Project arg0; 
     98  Customer arg1; 
     99 
     100  override protected void OnInit(EventArgs e) 
     101  { 
     102    Id<int, Project> id0; 
     103    if (this.TryParse0(out id0)) 
     104      arg0 = SomeDb.Projects.Single(x => x.Id == id0.Key); 
     105 
     106    Id<int, Customer> id1; 
     107    if (this.TryParse1(out arg1)) 
     108      arg1 = SomeDb.Customers.Single(x => x.Id == id1.Key); 
     109  } 
     110} 
     111}}}