Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

Implementing Generic Type Inference in C# reflectively -


i need generic type inference scripting language implementation , wondering if missing straightforward approach. moment let me ask type structure , ignore bounds. illustrate, here nested example:

t foo<t>( list<list<list<t>>> ) {...} 

now want test if can pass argument bar of type:

list<list<list<string>>> 

to method , later use makegenericmethod() discovered param type reify , invoke it.

from can tell, if manage construct open generic type equivalent foo argument (i.e. list<list<list<t>>>), not test isassignable(). i'm not sure if there trick checking assignability of open generic types or if it's not supported. guess if have can directly.

on reification - looks i'm going have recursively crawl through types find argument type matches location of type parameter , substitution... had been hoping might able somehow construct invocable method argument type more directly, i'm not seeing how this.

any advice who's gone through madness appreciated :)

thanks, pat niemeyer

so, believe have implemented going on assumption have reify types assignability comparison. near can tell there not way extract base type generic type in order perform assignment checks yourself. ended doing using getgenericarguments traverse method parameter type , argument type in parallel, performing sanity checks @ each step (number of generic params match, etc.) , once finding "naked" generic type param, noting corresponding (inferred) type in argument. can determine you've found type param using isgenericparameter. then, weirdly, have save types aside , use them instantiate method passing them in particular order makegenericmethod. order provided property on type itself, genericparameterposition, (again, weird) simple orderby sorts them out. after of normal rules seem apply.

-pat


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -