Specify Namespace using Fluent API
Closed this issue · 2 comments
Hello,
I would like to know if it is possible to specify a namespace of a type using Fluent API. Basically instead of [XmlTypeAttribute(Namespace="https://example.com")]
something like new ConfigurationContainer().Type<Person>().Namespace("https://example.com").
Thanks to issue #191, I know I can InspecingType
method to take namespace from attribute at the class, but readme says
All configurations (migrations, custom serializer...) are outside the class and not coupled to attributes or messy, arcane conventions
I have tried to follow the the InspectingType
method in the code, but codebase is too unfamilar to me and I got lost.
Hey there @jahav thank you for writing in with your question. Unfortunately we do not offer a way to explicitly set the namespace from our fluent API at present. As you pointed out that can still be achieved by making use of InspectingType
which will make use of the applied attribute and emit/read this way. We have a test you can explore as an example here:
Please note that the readme is in reference to default behavior and classical behavior can be somewhat attained with methods such as InspectingType
. Namespace is an interesting factor as we tried to place emphasis on object graph serialization so the generated namespaces are more Xaml-like than classical XML serialization, if that makes sense. In obvious hindsight now it would have been nice to include this as well in the fluent API but as stated it does not presently exist.
It may be possible to add this functionality via fluent API and I would be willing to work with you with a PR if you (and/or others) choose to provide one.
If you have any further questions please do follow up and I will do my best to assist you. 👍
Thank you for your answer and time. I will try to take a stab at it, but if nothing comes out of it, it's enought that there is a way to specify the namespace.