I have a custom class that has some properties from an external dll ( i cannot change this dll class)
If property's class has an empty constructer then this property is serialized but if there is only one constructer that you have to give parameters then it cannot serialize.
For example I created an instance from this class and tried to serialize and result is "[]"
here is the class
public class Shape : ShapeBase,
{
public Shape(DocumentBase doc, ShapeType shapeType);
public Chart Chart { get; }
public bool ExtrusionEnabled { get; }
public Fill Fill { get; }
public Color FillColor { get; set; }
public bool Filled { get; set; }
public Paragraph FirstParagraph { get; }
public bool HasChart { get; }
public bool HasImage { get; }
public ImageData ImageData { get; }
public Paragraph LastParagraph { get; }
public override NodeType NodeType { get; }
public OleFormat OleFormat { get; }
public bool ShadowEnabled { get; }
public SignatureLine SignatureLine { get; }
public StoryType StoryType { get; }
public Stroke Stroke { get; }
public Color StrokeColor { get; set; }
public bool Stroked { get; set; }
public double StrokeWeight { get; set; }
public TextBox TextBox { get; }
public TextPath TextPath { get; }
public override bool Accept(DocumentVisitor visitor);
}
and i try to serialize like that
Shape shape = new Shape(_wordDocument, ShapeType.TextPlainText);
string json = JsonConvert.SerializeObject(shape, Formatting.Indented);
but other class is like
public class PdfSaveOptions : FixedPageSaveOptions
{
public PdfSaveOptions();
public int BookmarksOutlineLevel { get; set; }
public PdfCompliance Compliance { get; set; }
public bool CreateNoteHyperlinks { get; set; }
public PdfCustomPropertiesExport CustomPropertiesExport { get; set; }
public PdfDigitalSignatureDetails DigitalSignatureDetails { get; set; }
public override DmlEffectsRenderingMode DmlEffectsRenderingMode { get; set; }
public bool DownsampleImages { get; set; }
public DownsampleOptions DownsampleOptions { get; }
.......
}
it is serialized.
So I also tried to use some options like
ConstructorHandling = ConstructorHandling.AllowNonPublicDefaultConstructor
but did not work.