i'm implementing rest
service json
message format using wcf
. have method should take argument of different types (but derived form basic class). , wonder if approach use extended class conversion operators in case?
example (ommiting datacontract
, datamember
etc.):
class classone { public string name { get; set; } } class classtwo : classone { public int { get; set; } } class classthree : classone { public int b { get; set; } } class classextended { public string name { get; set; } public int { get; set; } public int b { get; set; } public static implicit operator classtwo(classextended extended) { return new classtwo() { name = extended.name, = extended.a }; } public static implicit operator classthree(classextended extended) { return new classthree() { name = extended.name, b = extended.b }; } } void test(classextended extended) { // using classthree here }
while haven't used restful services in wcf, use knowntypes time handle polymorphism on our datacontracts
here's link more info: http://msdn.microsoft.com/en-us/library/ms730167.aspx
Comments
Post a Comment