Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ParameterBinding/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableAttribute.cs @ 4949

Last change on this file since 4949 was 4068, checked in by swagner, 14 years ago

Sorted usings and removed unused usings in entire solution (#1094)

File size: 2.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Text;
24
25namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
26
27
28  /// <summary>
29  /// Mark the member of a class to be considered by the <c>StorableSerializer</c>.
30  /// The class must be marked as <c>[StorableClass]</c> and the
31  /// <c>StorableClassType</c> should be set to <c>MarkedOnly</c> for
32  /// this attribute to kick in.
33  /// </summary>
34  [AttributeUsage(
35    AttributeTargets.Field | AttributeTargets.Property,
36    AllowMultiple = false,
37    Inherited = false)]
38  public class StorableAttribute : Attribute {
39
40    /// <summary>
41    /// An optional name for this member that will be used during serialization.
42    /// This allows to rename a field/property in code but still be able to read
43    /// the old serialized format.
44    /// </summary>
45    /// <value>The name.</value>
46    public string Name { get; set; }
47
48
49    /// <summary>
50    /// A default value in case the field/property was not present or not serialized
51    /// in a previous version of the class and could therefore be absent during
52    /// deserialization.
53    /// </summary>
54    /// <value>The default value.</value>
55    public object DefaultValue { get; set; }
56
57    /// <summary>
58    /// Returns a <see cref="System.String"/> that represents this instance.
59    /// </summary>
60    /// <returns>
61    /// A <see cref="System.String"/> that represents this instance.
62    /// </returns>
63    public override string ToString() {
64      StringBuilder sb = new StringBuilder();
65      sb.Append("[Storable");
66      if (Name != null || DefaultValue != null)
67        sb.Append('(');
68      if (Name != null) {
69        sb.Append("Name = \"").Append(Name).Append("\"");
70        if (DefaultValue != null)
71          sb.Append(", ");
72      }
73      if (DefaultValue != null)
74        sb.Append("DefaultValue = \"").Append(DefaultValue).Append("\"");
75      if (Name != null || DefaultValue != null)
76        sb.Append(')');
77      sb.Append(']');
78      return sb.ToString();
79    }
80  }
81}
Note: See TracBrowser for help on using the repository browser.