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# - DataContract Serialize abstract class -


i have interface iserviceinfo , abstract class serviceinfo. there several classes inherited serviceinfo, coreserviceinfo, moduleserviceinfo etc. there service contract named rootservice returns iserviceinfo.

 public iserviceinfo getserviceinfo()  {      return (iserviceinfo)new coreserviceinfo();  } 

i having problem serializing. can use serviceknowntype identify base class, , knowntype identify child class.

problem not know serviceinfo child, since application can have plugins different child inherited serviceinfo, cannot tell serializer have child in serialized xml.

i can ignore abstract class, contains common implementation need keep it. work around can have class "sampleserviceinfo" , convert info classes sampleserviceinfo , return service method, , define knowntype serviceinfo class.

[knowntype(typeof(sampleserviceinfo))] public class serviceinfo : iserviceinfo 

but not sound pretty way it. please suggest. need write custom serializer? there way serialize base , ignoring child when both has same members?

get types in loaded assemblies implement given abstract class or interface(ref:implementations of interface through reflection)

 var alltypes =  appdomain             .currentdomain             .getassemblies()             .selectmany(assembly => assembly.gettypes())             .where(type => typeof(a).isassignablefrom(type)); 

then create serializer passing alltypes known types parameter, below

var serializer = new datacontractserializer(typeof(a), alltypes); 

that's - able serialize , deserialize type derives (a class or interface, if interface, serializer writes elements deriving xs:anytype.


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 -