Changes between Version 3 and Version 4 of WikiStart
- Timestamp:
- 01/27/14 11:34:27 (11 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
WikiStart
v3 v4 7 7 1. IContinuation for specifying page parameter types 8 8 1. Unsafe<T> for specifying unsafe/insecure page parameters 9 1. Continuation.ToUrloverloads for generating URLs from continuations + arguments10 1. Continuation.TryParseXfor parsing page parameters9 1. {{{Continuation.ToUrl}}} overloads for generating URLs from continuations + arguments 10 1. {{{Continuation.TryParseX}}} for parsing page parameters 11 11 12 12 == Typed Page Parameters == … … 60 60 3.AsParam(), "hello world!".AsParam()); 61 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: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 63 {{{ 64 64 var url = Continuation.Params(3.AsParam(), "hello world!".AsParam()); … … 74 74 .ToUrl<SomePage>(); 75 75 }}} 76 77 == Parsing Page Parameters == 78 79 Inside 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 {{{ 81 public 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 }}} 93 The above will only work if the types are IConvertible. For non-IConvertible values, you instead need to parse an Id<TKey, TType>: 94 {{{ 95 public 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 }}}