Inheritance / polymorphism and serialization of WCF

I have a class ReportDef, which is a concrete class, which I decorated with attributes [DataContract]and [DataMember]as needed. ReportDefIt is the assembly A1with my ServiceContract, IReportService. Then I have another class UiReportDefthat comes from ReportDefand is in the assembly A2. UiReportDefdoes not have an additional state that the service takes care of.

I want to call my service with an instance UiReportDef. Is there a way (if not manually creating an instance ReportDefof UiReportDef) to do this if my service does not know about A2? I know about KnownType. I do not want to refer to A2.


EDIT: Here is a context that might simplify my question. My ServiceContractrealizes IReportServicethat defines the method RunReport(ReportDef report). ReportDefadorned with attribute DataContractand has private members adorned DataMember. UiReportDefis in the assembly, which depends on the assemblies associated with the UI, etc. I did not design the existing class hierarchy. I need to pass ReportDefsand UiReportDefs(as ReportDefs) to a new service. Since it ReportDefis specific, I would expect the serializer to process UiReportDefsas ReportDefsif there was no other information.

+3
source share
3 answers

I do not understand you.

, , , ?

, , ""

, , , .

-, , .

, , DTO. http://en.wikipedia.org/wiki/Data_Transfer_Object

+2
+1

WCF , -. , .

-3

Source: https://habr.com/ru/post/1707635/


All Articles