c# - Implement interface and use code from existing implementation of the interface -
i'm trying implement itableentity
interface can add [datacontract]
attribute on it. if implement interface myself, i'll have give readentity
, writeentity
methods body.
but there class implements itableentity
interface , gave readentity
, writeentity
methods body, tableentity.cs.
how can make implementation of interface use methods in tableentity
class?
[edit]
[datacontract] public class serializabletableentity : itableentity { private tableentity tableentity; public string etag { get; set; } public string partitionkey { get; set; } public string rowkey { get; set; } public datetimeoffset timestamp { get; set; } public serializabletableentity() { tableentity = new tableentity(); } public void readentity(idictionary<string, entityproperty> properties, microsoft.windowsazure.storage.operationcontext operationcontext) { tableentity.readentity(properties, operationcontext); } public idictionary<string, entityproperty> writeentity(microsoft.windowsazure.storage.operationcontext operationcontext) { return tableentity.writeentity(operationcontext); } }
the reason every property in stored table blank because writeentity , readentity use blank object store , write data.
you're delegating serialization of object 'tableentity' none of properties there.
suggestion: need implement of serializabletableentity's properties inside class derives tableentity, contain variable of type inside serializabletableentity entity, , delegate every member's property get/set serializabletableentity new object.
does make sense?
edit: code sample requested (you're not going enjoy though)
[datacontract] public class serializabletableentity : itableentity { private customentity tableentity; public string etag { { { return tableentity.etag; } set { tableentity.etag = value; } } public string partitionkey { { return tableentity.partitionkey; } set { tableentity.partitionkey = value; } } public string rowkey { { return tableentity.rowkey; } set { tableentity.rowkey = value; } } public datetimeoffset timestamp { { return tableentity.timestamp; } set { tableentity.timestamp = value; } } public string propertyone { { return tableentity.propertyone; } set { tableentity.propertyone = value; } } public serializabletableentity() { tableentity = new customentity(); } public void readentity(idictionary<string, entityproperty> properties, microsoft.windowsazure.storage.operationcontext operationcontext) { tableentity.readentity(properties, operationcontext); } public idictionary<string, entityproperty> writeentity(microsoft.windowsazure.storage.operationcontext operationcontext) { return tableentity.writeentity(operationcontext); } } public class customentity : tableentity { public string propertyone { get; set; } }
Comments
Post a Comment