CrystalXmlConverterAttribute
Namespace: SnowBank.Data.Xml · class
Implements: CrystalConverterAttribute
Mono-format alias that marks a partial class as a container of source-generated XML serializers
Remarks
Exactly equivalent to [CrystalConverter] plus [CrystalXmlOutput(...)] with the same parameters, and the shortest spelling for a container that only ever produces XML: no JSON entry point, no JSON proxy and no JSON facet is generated for its types.
Being mono-format, it does not combine with another output format: pairing it with [CrystalJsonOutput] is rejected (CRYS0002). A container that produces both formats spells out [CrystalConverter], [CrystalJsonOutput] and [CrystalXmlOutput].
Sample: [CrystalXmlConverter(CrystalXmlSerializerDefaults.DataContractCompat)] [CrystalSerializable(typeof(LegacyOrder))] public static partial class LegacyRenderSerializers { // generated code will be inserted here }
Constructors
CrystalXmlConverterAttribute
CrystalXmlConverterAttribute()
Use this class as a container for source-generated XML serializers
CrystalXmlConverterAttribute(CrystalXmlSerializerDefaults defaults)
Enables XML output for this serializer container
defaults— Default settings used for the generated converters
Properties
DictionaryFormat
CrystalXmlDictionaryFormat DictionaryFormat { get; set; }
Default representation for dictionary-like members of this container that do not override it with DictionaryFormat
OmitNamespaces
bool OmitNamespaces { get; set; }
Strips namespaces and prefixes from the DataContractCompat output, keeping the rest of that format
Under this option the DataContract profile writes no XML declaration, no prefix and no xmlns, ever: element names keep their local name only, the nil and type attributes are written bare, and a type value is the local contract name with no namespace half. Everything else about the format is unchanged, which is the point: the null markers, the member order, the lexical forms and the KeyValueOfXY entries all stay.
It exists for one reason: an application whose stored documents were written by a namespace-free writer reads them back by local name. A namespaced document would not match. So this is the output to name when the documents already exist, and the default is the output to name for anything new.
What it costs: type="RangeCriterion" has lost the namespace half of its qualified name, so two derived types with the same local name in different contract namespaces become the same annotation in the output.
Generation-time, like the CrystalXmlSerializerDefaults preset: the generated code bakes its names as frozen literals, so a name exists with a namespace or without one and never both. On General, which has no namespaces to strip, the option does nothing and the generator says so (CXML0012).