I’m new in XSD side. Would anybody do let me know either there is a way to Generate a Class from XSD (ComplexType) with parameterized constructor.
For Example. I’ve following XSD with a ComplexType A and I want that when proxy generated from this XSD. type A contains a constructor with a string value.
<xs:schema targetNamespace="http://tempuri.org/XMLSchema.xsd" elementFormDefault="qualified" xmlns="http://tempuri.org/XMLSchema.xsd" xmlns:mstns="http://tempuri.org/XMLSchema.xsd" xmlns:xs="http://www.w3.org/2001/XMLSchema"> <xs:complexType name="A"> <xs:sequence> <xs:element name="property1" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema>
A _object = new A(“this is value”);
This is possible or not?
Any help in this regards will be highly appreciable.
/Rizwan
Seeing your other post that involves the .NET platform, I assume you’re after the same here, too.
The answer is no; in general XSD to code generators use only default constructors (parameterless) for reasons related to deserialization.
You could use initializers.