Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/09 12:58:14 (15 years ago)
Author:
epitzer
Message:

Format white space. (Ctrl-K, Ctrl-D) (#548)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/3.3/Default/Xml/XmlGenerator.cs

    r1564 r1566  
    2121    public const string METAINFO = "METAINFO";
    2222  }
    23  
     23
    2424  public class XmlGenerator : GeneratorBase<string> {
    25    
     25
    2626    private int depth;
    2727
     
    4545      if (type == NodeType.End)
    4646        sb.Append('/');
    47       sb.Append(name);     
     47      sb.Append(name);
    4848      foreach (var attribute in attributes) {
    4949        if (attribute.Value != null && !string.IsNullOrEmpty(attribute.Value.ToString())) {
     
    5858        sb.Append('/');
    5959      sb.Append(">");
    60       return sb.ToString();     
     60      return sb.ToString();
    6161    }
    6262
     
    6565    }
    6666
    67     protected override string Format(BeginToken beginToken) {           
     67    protected override string Format(BeginToken beginToken) {
    6868      var attributes = new Dictionary<string, object> {
    6969        {"name", beginToken.Name},
     
    7676    }
    7777
    78     protected override string Format(EndToken endToken) {     
     78    protected override string Format(EndToken endToken) {
    7979      depth -= 1;
    8080      return Prefix + "</" + XmlStrings.COMPOSITE + ">\r\n";
    8181    }
    8282
    83     protected override string Format(PrimitiveToken dataToken) {     
     83    protected override string Format(PrimitiveToken dataToken) {
    8484      var attributes =
    8585        new Dictionary<string, object> {
     
    8989      return Prefix +
    9090        FormatNode(XmlStrings.PRIMITIVE, attributes, NodeType.Start) +
    91         ((XmlString)dataToken.SerialData).Data + "</" + XmlStrings.PRIMITIVE + ">\r\n";     
     91        ((XmlString)dataToken.SerialData).Data + "</" + XmlStrings.PRIMITIVE + ">\r\n";
    9292    }
    9393
    94     protected override string Format(ReferenceToken refToken) {     
     94    protected override string Format(ReferenceToken refToken) {
    9595      var attributes = new Dictionary<string, object> {
    9696        {"ref", refToken.Id},
    97         {"name", refToken.Name}};                                       
    98       return Prefix + FormatNode(XmlStrings.REFERENCE, attributes, NodeType.Inline) + "\r\n"; 
     97        {"name", refToken.Name}};
     98      return Prefix + FormatNode(XmlStrings.REFERENCE, attributes, NodeType.Inline) + "\r\n";
    9999    }
    100100
    101     protected override string Format(NullReferenceToken nullRefToken) {     
     101    protected override string Format(NullReferenceToken nullRefToken) {
    102102      var attributes = new Dictionary<string, object>{
    103         {"name", nullRefToken.Name}};     
     103        {"name", nullRefToken.Name}};
    104104      return Prefix + FormatNode(XmlStrings.NULL, attributes, NodeType.Inline) + "\r\n";
    105105    }
     
    127127    }
    128128
    129     public static void Serialize(object o, string filename) {     
     129    public static void Serialize(object o, string filename) {
    130130      Serialize(o, filename, ConfigurationService.Instance.GetDefaultConfig(new XmlFormat()));
    131131    }
     
    135135      XmlGenerator generator = new XmlGenerator();
    136136      ZipOutputStream zipStream = new ZipOutputStream(File.Create(filename));
    137       zipStream.SetLevel(9);     
    138       zipStream.PutNextEntry(new ZipEntry("data.xml"));     
     137      zipStream.SetLevel(9);
     138      zipStream.PutNextEntry(new ZipEntry("data.xml"));
    139139      StreamWriter writer = new StreamWriter(zipStream);
    140       ILog logger = Logger.GetDefaultLogger();     
     140      ILog logger = Logger.GetDefaultLogger();
    141141      foreach (ISerializationToken token in serializer) {
    142142        string line = generator.Format(token);
     
    151151        logger.Debug(line);
    152152      }
    153       writer.Flush();           
    154       zipStream.Close();     
     153      writer.Flush();
     154      zipStream.Close();
    155155    }
    156156
Note: See TracChangeset for help on using the changeset viewer.