public void TestCase() { Style style = new HyphenStyle(); Format format = new Format(style); Persister writer = new Persister(format); Persister reader = new Persister(); CaseExample example = reader.read(CaseExample.class, SOURCE);
/// <summary> /// Constructor for the <c>Formatter</c> object. This creates /// an object that can be used to write XML in an indented format /// to the specified writer. The XML written will be well formed. /// </summary> /// <param name="result"> /// this is where the XML should be written to /// </param> /// <param name="format"> /// this is the format object to use /// </param> public Formatter(TextWriter result, Format format){ this.indenter = new Indenter(format); this.buffer = new OutputBuffer(); this.prolog = format.Prolog; this.result = result; }
/// <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; }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use the provided format /// instructions. The persister uses the <c>Format</c> object /// to structure the generated XML. It determines the indent size /// of the document and whether it should contain a prolog. /// </summary> /// <param name="format"> /// this is used to structure the generated XML /// </param> public Persister(Format format) { this(new TreeStrategy(), format); }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use the provided filter. /// This persister will replace all variables encountered when /// deserializing an object with mappings found in the filter. /// <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="filter"> /// the filter used to replace template variables /// </param> /// <param name="format"> /// this is used to format the generated XML document /// </param> public Persister(Strategy strategy, Filter filter, Format format) { this(strategy, filter, new EmptyMatcher(), format); }
/// <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="format"> /// this is used to format the generated XML document /// </param> public Persister(Strategy strategy, Matcher matcher, Format format) { this(strategy, new PlatformFilter(), matcher, format); }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use the provided filter. /// This persister will replace all variables encountered when /// deserializing an object with mappings found in the filter. /// </summary> /// <param name="filter"> /// the filter used to replace template variables /// </param> /// <param name="matcher"> /// this is used to customize the transformations /// </param> /// <param name="format"> /// this is used to structure the generated XML /// </param> public Persister(Filter filter, Matcher matcher, Format format) { this(new TreeStrategy(), filter, matcher, format); }
/// <summary> /// This is used to create an <c>OutputNode</c> that can be /// used to write a well formed XML document. The writer specified /// will have XML elements, attributes, and text written to it as /// output nodes are created and populated. /// </summary> /// <param name="result"> /// This contains the result of the generated XML. /// </param> /// <param name="format"> /// This is the format to use for the document. /// </param> public static OutputNode Write(TextWriter result, Format format) { return new NodeWriter(result, format).WriteRoot(); }
/// <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. /// </summary> /// <param name="matcher"> /// this is used to customize the transformations /// </param> /// <param name="format"> /// this is used to structure the generated XML /// </param> public Persister(Matcher matcher, Format format) { this(new TreeStrategy(), matcher, format); }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use a strategy object. /// 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="format"> /// this is used to structure the generated XML /// </param> public Persister(Strategy strategy, Format format) { this(strategy, new HashMap(), format); }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use a platform filter /// object using the overrides within the provided map. This means /// that template variables will be replaced firstly with mappings /// from within the provided map, followed by system properties. /// </summary> /// <param name="filter"> /// this is the map that contains the overrides /// </param> /// <param name="format"> /// this is the format used to format the documents /// </param> public Persister(Dictionary filter, Format format) { this(new PlatformFilter(filter)); }
/// <summary> /// Constructor for the <c>Indenter</c> object. This will /// create an indent that uses the specified number of spaces to /// create each entry pushed on to the stack. This uses a cache /// of the specified size, which is used to optimize the object. /// </summary> /// <param name="format"> /// Determines the number of spaces per indent. /// </param> /// <param name="size"> /// This is the initial size of the indent cache. /// </param> private Indenter(Format format, int size) { this.cache = new Cache(size); this.indent = format.Indent; }
/// <summary> /// Constructor for the <c>Indenter</c> object. This will /// create an indent that uses the specified number of spaces to /// create each entry pushed on to the stack. This uses a cache /// size of sixteen, which should be sufficient for most files. /// </summary> /// <param name="format"> /// Determines the number of spaces per indent. /// </param> public Indenter(Format format) : this(format, 16) { }
/// <summary> /// Constructor for the <c>NodeWriter</c> object. This will /// create the object that is used to control an output elements /// access to the generated XML document. This keeps a stack of /// active and uncommitted elements. /// </summary> /// <param name="result"> /// this is the output for the resulting document /// </param> /// <param name="format"> /// this is used to format the generated document /// </param> public NodeWriter(Writer result, Format format) { this(result, format, false); }
/// <summary> /// Constructor for the <c>Persister</c> object. This is used /// to create a serializer object that will use the provided filter. /// This persister will replace all variables encountered when /// deserializing an object with mappings found in the filter. /// <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="data"> /// the filter data used to replace template variables /// </param> /// <param name="format"> /// this is used to format the generated XML document /// </param> public Persister(Strategy strategy, Dictionary data, Format format) { this(strategy, new PlatformFilter(data), format); }
/// <summary> /// Constructor for the <c>NodeWriter</c> object. This will /// create the object that is used to control an output elements /// access to the generated XML document. This keeps a stack of /// active and uncommitted elements. /// </summary> /// <param name="result"> /// this is the output for the resulting document /// </param> /// <param name="format"> /// this is used to format the generated document /// </param> /// <param name="verbose"> /// this determines if we expand the namespaces /// </param> private NodeWriter(Writer result, Format format, bool verbose) { this.writer = new Formatter(result, format); this.active = new HashSet(); this.stack = new OutputStack(active); this.verbose = verbose; }
/// <summary> /// Constructor for the <c>NodeWriter</c> object. This will /// create the object that is used to control an output elements /// access to the generated XML document. This keeps a stack of /// active and uncommitted elements. /// </summary> /// <param name="result"> /// This is the output for the resulting document. /// </param> /// <param name="format"> /// This is used to format the generated document. /// </param> public NodeWriter(TextWriter result, Format format) : this(result, format, false) { }