I have a class RequestDetail. There are 2 classes classA and classB derived from it such that each of them has their own property:
public partial classA : RequestDetail { ..... }
public partial classB : RequestDetail { ..... }
I am writing a method CreateMethod1(ClassA a) and CreateMethod2(ClassB b).
Both methods doing the same stuff except some minor difference. I would like to write a generic method and call that method by passing the reference in CreateMethod1 and CreateMethod2.
Can anyone help me in doing this?
THanks
EDIT:
What I have excluded is I have received a WSDL which when generated gives me four separate classes that inherit from a base class with around 20 properties. They only differ very slightly, to be exact 2 classes contain the same field (IsUrgent), the third contains (Ticket and Reason) and the fourth contains (BudgetCode) The persistance however is exactly the same for all implementations. I dont want to create 4 seperate methods to persist the same information.
Its worth noting the classes are partial.
xsd looks like following
<xs:complexType name="ClassA">
<xs:complexContent>
<xs:extension base="IARequestDetails">
<xs:sequence>
<xs:element name="IsUrgent" type="IAUrgency"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="ClassB">
<xs:complexContent>
<xs:extension base="IARequestDetails">
<xs:sequence>
<xs:element name="BudgetCode" type="ProjectBudgetCode"/>
<xs:element name="IsUrgent" type="IAUrgency"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
Here is a solution using partial classes an interface and generic constraints … you will need to build the list of parameters that need to be returned in the Params implemenation for each of your sub classes, super class properties are naturally available.