Changes between Version 2 and Version 3 of WikiStart

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

--

Legend:

Unmodified
Added
Removed
Modified
  • WikiStart

    v2 v3  
    1919} 
    2020}}} 
    21 This declares a page that accepts a protected Int32 as the first argument, and a protected string as the second argument. By default, all types specified in an IContinuation<...> declaration will be protected, which means they cannot be changed by clients. If you wish to declare that a certain page parameter is unprotected, then you need only wrap it with Unsafe<T>. For instance, suppose the integer argument from the above example should be unprotected: 
    22 {{{ 
    23 public class SomePage : System.Web.Page, IContinuation<Unsafe<int>, string> 
    24 { 
    25   ... 
    26 } 
    27 }}} 
     21This declares a page that accepts a protected Int32 as the first argument, and a protected string as the second argument. By default, all types specified in an IContinuation<...> declaration will be protected, which means they cannot be changed by clients. 
     22 
    2823Any type can appear as an argument to IContinuation<...>, not just primitive values. In fact, it's good practice in Clavis not to use primitive types since parameter names are generated from the class name by default: 
    2924{{{ 
    30 public class SomePage : System.Web.Page, IContinuation<Unsafe<Project>, Customer> 
     25public class SomePage : System.Web.Page, IContinuation<Project, Customer> 
    3126{ 
    3227  ... 
     
    4035} 
    4136}}} 
     37 
     38== Unsafe Parameters == 
     39 
     40If you wish to declare that a certain page parameter is unprotected, then you need only wrap it with Unsafe<T>. For instance, suppose the integer argument from the first example should be unprotected: 
     41{{{ 
     42public class SomePage : System.Web.Page, IContinuation<Unsafe<int>, string> 
     43{ 
     44  ... 
     45} 
     46}}} 
    4247IEnumerable<T> and Unsafe<T> can also be nested, so you can have an unsafe list of objects as a parameter: 
    4348{{{ 
     
    4752} 
    4853}}} 
     54 
     55== Generating URLs == 
     56 
     57You can easily generate a URL from a continuation with its arguments like so: 
     58{{{ 
     59var url = Continuation.ToUrl<SomePage, int, string>( 
     60              3.AsParam(), "hello world!".AsParam()); 
     61}}} 
     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: 
     63{{{ 
     64var url = Continuation.Params(3.AsParam(), "hello world!".AsParam()); 
     65                      .ToUrl<SomePage>(); 
     66}}} 
     67The {{{Param.AsParam()}}} extension methods are fully defined over all [http://msdn.microsoft.com/en-us/library/system.iconvertible.aspx IConvertible] types. Types that aren't IConvertible require that you provide an ICovertible type as a key: 
     68{{{ 
     69public class SomePage : System.Web.Page, IContinuation<Project, Customer> { ... } 
     70 
     71... 
     72 
     73var url = Continuation.Params(project.AsParam(project.Id), customer.AsParam(customer.Id)); 
     74                      .ToUrl<SomePage>(); 
     75}}}