The Style interface is used to represent an XML style that can be applied to a serialized object. A style can be used to modify the element and attribute names for the generated document. Styles can be used to generate hyphenated or camel case XML. <example-element> <child-element example-attribute='example'> <inner-element>example</inner-element> </child-element> </example-element> Above the hyphenated XML elements and attributes can be generated from a style implementation. Styles enable the same objects to be serialized in different ways, generating different styles of XML without having to modify the class schema for that object.
Ejemplo n.º 1
0
 /// <summary>
 /// Constructor for the <c>CompositeValue</c> object. This
 /// will create an object capable of reading an writing composite
 /// values from an XML element. This also allows a parent element
 /// to be created to wrap the key object if desired.
 /// </summary>
 /// <param name="context">
 /// this is the root context for the serialization
 /// </param>
 /// <param name="entry">
 /// this is the entry object used for configuration
 /// </param>
 /// <param name="type">
 /// this is the type of object the value represents
 /// </param>
 public CompositeValue(Context context, Entry entry, Type type) {
    this.root = new Traverser(context);
    this.style = context.Style;
    this.context = context;
    this.entry = entry;
    this.type = type;
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Constructor for the <c>CompositeMap</c> object. This will
 /// create a converter that is capable of writing map objects to
 /// and from XML. The resulting XML is configured by an annotation
 /// such that key values can attributes and values can be inline.
 /// </summary>
 /// <param name="context">
 /// this is the root context for the serialization
 /// </param>
 /// <param name="entry">
 /// this provides configuration for the resulting XML
 /// </param>
 /// <param name="type">
 /// this is the map type that is to be converted
 /// </param>
 public CompositeMap(Context context, Entry entry, Type type) {
    this.factory = new MapFactory(context, type);
    this.value = entry.GetValue(context);
    this.key = entry.GetKey(context);
    this.style = context.getStyle();
    this.entry = entry;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Constructor for the <c>CamelCaseStyle</c> object. This
 /// is used to create a style that will create camel case XML
 /// attributes and elements allowing a consistent format for
 /// generated XML. Both the attribute an elements are configurable.
 /// </summary>
 /// <param name="element">
 /// if true the element will start as upper case
 /// </param>
 /// <param name="attribute">
 /// if true the attribute starts as upper case
 /// </param>
 public CamelCaseStyle(bool element, bool attribute) {
    this.style = new CamelCaseBuilder(element, attribute);
    this.builder = new Builder(style);
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Constructor for the <c>Source</c> object. This is used to
 /// maintain a context during the serialization process. It holds
 /// the <c>Strategy</c> and <c>Context</c> used in the
 /// serialization process. The same source instance is used for
 /// each XML element evaluated in a the serialization process.
 /// </summary>
 /// <param name="strategy">
 /// this is used to resolve the classes used
 /// </param>
 /// <param name="support">
 /// this is the context used to process strings
 /// </param>
 /// <param name="style">
 /// this is the style used for the serialization
 /// </param>
 /// <param name="strict">
 /// this determines whether to read in strict mode
 /// </param>
 public Source(Strategy strategy, Support support, Style style, bool strict) {
    this.filter = new TemplateFilter(this, support);
    this.engine = new TemplateEngine(filter);
    this.session = new Session();
    this.strategy = strategy;
    this.support = support;
    this.strict = strict;
    this.style = style;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Constructor for the <c>Source</c> object. This is used to
 /// maintain a context during the serialization process. It holds
 /// the <c>Strategy</c> and <c>Context</c> used in the
 /// serialization process. The same source instance is used for
 /// each XML element evaluated in a the serialization process.
 /// </summary>
 /// <param name="strategy">
 /// this is used to resolve the classes used
 /// </param>
 /// <param name="support">
 /// this is the context used to process strings
 /// </param>
 /// <param name="style">
 /// this is the style used for the serialization
 /// </param>
 public Source(Strategy strategy, Support support, Style style) {
    this(strategy, support, style, true);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Constructor for the <c>Persister</c> object. This is used
 /// to create a serializer object that will use the provided matcher
 /// for customizable transformations. The <c>Matcher</c> will
 /// enable the persister to determine the correct way to transform
 /// the types that are not annotated and considered primitives.
 /// <p>
 /// This persister will use the provided <c>Strategy</c> to
 /// intercept the XML elements in order to read and write persistent
 /// data, such as the class name or version of the document.
 /// </summary>
 /// <param name="strategy">
 /// this is the strategy used to resolve classes
 /// </param>
 /// <param name="matcher">
 /// this is used to customize the transformations
 /// </param>
 /// <param name="filter">
 /// the filter used to replace template variables
 /// </param>
 public Persister(Strategy strategy, Filter filter, Matcher matcher, Format format) {
    this.support = new Support(filter, matcher);
    this.style = format.Style;
    this.strategy = strategy;
    this.format = format;
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Constructor for the <c>HyphenStyle</c> object. This is
 /// used to create a style that will hyphenate XML attributes
 /// and elements allowing a consistent format for generated XML.
 /// </summary>
 public HyphenStyle() {
    this.style = new HyphenBuilder();
    this.builder = new Builder(style);
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Constructor for the <c>PrimitiveKey</c> object. This is
 /// used to create the key object which converts the map key to an
 /// instance of the key type. This can also resolve references.
 /// </summary>
 /// <param name="context">
 /// this is the context object used for serialization
 /// </param>
 /// <param name="entry">
 /// this is the entry object that describes entries
 /// </param>
 /// <param name="type">
 /// this is the type that this converter deals with
 /// </param>
 public PrimitiveKey(Context context, Entry entry, Type type) {
    this.factory = new PrimitiveFactory(context, type);
    this.root = new Primitive(context, type);
    this.style = context.Style;
    this.context = context;
    this.entry = entry;
    this.type = type;
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Constructor for the <c>Traverser</c> object. This creates
 /// a traverser that can be used to perform serialization or
 /// or deserialization of an object. This requires a source object.
 /// </summary>
 /// <param name="context">
 /// the context object used for the traversal
 /// </param>
 public Traverser(Context context) {
    this.style = context.Style;
    this.context = context;
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Constructor for the <c>Format</c> object. This creates an
 /// object that is used to describe how the formatter should create
 /// the XML document. This constructor uses the specified indent
 /// size and the text to use in the generated prolog.
 /// </summary>
 /// <param name="indent">
 /// This is the number of spaces used in the indent.
 /// </param>
 /// <param name="prolog">
 /// This is the prolog for the generated XML document.
 /// </param>
 /// <param name="style">
 /// This is the style to apply to the format object.
 /// </param>
 public Format(int indent, String prolog, Style style) {
    this.prolog = prolog;
    this.indent = indent;
    this.style = style;
 }
Ejemplo n.º 11
0
 /// <summary>
 /// Constructor for the <c>Format</c> object. This creates an
 /// object that is used to describe how the formatter should create
 /// the XML document. This constructor uses the specified indent
 /// size and the style provided to style the XML document.
 /// </summary>
 /// <param name="indent">
 /// This is the number of spaces used in the indent.
 /// </param>
 /// <param name="style">
 /// This is the style to apply to the format object.
 /// </param>
 public Format(int indent, Style style) : this(indent, null, style) {
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Constructor for the <c>Format</c> object. This creates an
 /// object that is used to describe how the formatter should create
 /// the XML document. This constructor uses the specified style
 /// to style the attributes and elements of the XML document.
 /// </summary>
 /// <param name="style">
 /// This is the style to apply to the format object.
 /// </param>
 public Format(Style style) : this(3, null, style) {
 }