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.

c# - How can I make this generic method more flexible? -


i'm working library (treeview in gtk specific) allows sort passing function compares 2 rows. simplified version of function signature might this:

int somesortfunc (foo foo1, foo foo2) {     // return -1 if foo1 < foo2, 0 if foo1 == foo2, 1 if foo1 > foo2 } 

i can't implement foo.compareto (foo), because want sort differently depending on context. there several fields in foo sort by. sort priority of each field depends on context. write this:

int sortfunc<t> (foo foo1, foo foo2, params func<foo, t> [] selectors)     t : icomparable<t> {     return selectors         .select (s => s (foo1).compareto (s (foo2)))         .firstordefault (i => != 0); }  // compare somestring, someint, somebar int somesortfunc (foo foo1, foo foo2) {     // won't compile, because string, int, , bar different types.     return sortfunc (foo1, foo2, f => f.somestring, f => f.someint, f => f.somebar); } 

this won't compile, because t in func<foo, t> different string, int, , bar : icomparable<bar> (in other words, there no way resolve t in sortfunc<t>).

is there way write function such each selector can return different type, long each type sometype implements icomparable<sometype>?

i simplify , accept function returning non-generic icomparable. can pass in functions returning primitives without needing figure out number of generic type parameters function need, truthfully need type parameters each of functions provided.

int sortfunc(foo foo1, foo foo2, params func<foo, icomparable>[] selectors) 

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 -