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 | | }}} |
| 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. |
| 22 | |
| 54 | |
| 55 | == Generating URLs == |
| 56 | |
| 57 | You can easily generate a URL from a continuation with its arguments like so: |
| 58 | {{{ |
| 59 | var url = Continuation.ToUrl<SomePage, int, string>( |
| 60 | 3.AsParam(), "hello world!".AsParam()); |
| 61 | }}} |
| 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: |
| 63 | {{{ |
| 64 | var url = Continuation.Params(3.AsParam(), "hello world!".AsParam()); |
| 65 | .ToUrl<SomePage>(); |
| 66 | }}} |
| 67 | The {{{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 | {{{ |
| 69 | public class SomePage : System.Web.Page, IContinuation<Project, Customer> { ... } |
| 70 | |
| 71 | ... |
| 72 | |
| 73 | var url = Continuation.Params(project.AsParam(project.Id), customer.AsParam(customer.Id)); |
| 74 | .ToUrl<SomePage>(); |
| 75 | }}} |