Changeset 3016 for trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableAttribute.cs
- Timestamp:
- 03/14/10 00:42:28 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableAttribute.cs
r2994 r3016 9 9 10 10 /// <summary> 11 /// Mark the member of a class to be considered by the <c ode>StorableSerializer</code>.12 /// The class must be marked as <c ode>[StorableClass(StorableClassType.Empty)]</code> and the13 /// <c ode>StorableClassType</code> should be set to <code>MarkedOnly</code> for11 /// Mark the member of a class to be considered by the <c>StorableSerializer</c>. 12 /// The class must be marked as <c>[StorableClass(StorableClassType.Empty)]</c> and the 13 /// <c>StorableClassType</c> should be set to <c>MarkedOnly</c> for 14 14 /// this attribute to kick in. 15 15 /// </summary> … … 22 22 /// <summary> 23 23 /// An optional name for this member that will be used during serialization. 24 ///25 24 /// This allows to rename a field/property in code but still be able to read 26 25 /// the old serialized format. 27 26 /// </summary> 27 /// <value>The name.</value> 28 28 public string Name { get; set; } 29 29 … … 34 34 /// deserialization. 35 35 /// </summary> 36 /// <value>The default value.</value> 36 37 public object DefaultValue { get; set; } 37 38 39 /// <summary> 40 /// Returns a <see cref="System.String"/> that represents this instance. 41 /// </summary> 42 /// <returns> 43 /// A <see cref="System.String"/> that represents this instance. 44 /// </returns> 38 45 public override string ToString() { 39 46 StringBuilder sb = new StringBuilder(); … … 60 67 BindingFlags.DeclaredOnly; 61 68 69 /// <summary> 70 /// Encapsulate information about storable members of a class 71 /// that have the storable attribute set. 72 /// </summary> 62 73 public sealed class StorableMemberInfo { 74 75 /// <summary> 76 /// Gets the [Storable] attribute itself. 77 /// </summary> 78 /// <value>The [Storable] attribute.</value> 63 79 public StorableAttribute Attribute { get; private set; } 80 81 /// <summary> 82 /// Gets the .NET reflection MemberInfo. 83 /// </summary> 84 /// <value>The member info.</value> 64 85 public MemberInfo MemberInfo { get; private set; } 86 87 88 /// <summary> 89 /// Gets disentangled name (i.e. unique access name regardless of 90 /// type hierarchy. 91 /// </summary> 92 /// <value>The disentangled name.</value> 65 93 public string DisentangledName { get; private set; } 94 95 96 /// <summary> 97 /// Gets the fully qualified member name. 98 /// </summary> 99 /// <value>The the fully qualified member name.</value> 66 100 public string FullyQualifiedMemberName { 67 101 get { … … 73 107 } 74 108 } 75 public StorableMemberInfo(StorableAttribute attribute, MemberInfo memberInfo) { 109 110 internal StorableMemberInfo(StorableAttribute attribute, MemberInfo memberInfo) { 76 111 this.Attribute = attribute; 77 112 this.MemberInfo = memberInfo; 78 113 } 114 115 /// <summary> 116 /// Returns a <see cref="System.String"/> that represents this instance. 117 /// </summary> 118 /// <returns> 119 /// A <see cref="System.String"/> that represents this instance. 120 /// </returns> 79 121 public override string ToString() { 80 122 return new StringBuilder() … … 82 124 .Append(MemberInfo).Append('}').ToString(); 83 125 } 84 public void SetDisentangledName(string name) { 126 127 internal void SetDisentangledName(string name) { 85 128 DisentangledName = Attribute.Name ?? name; 86 129 } 130 131 /// <summary> 132 /// Gets the delcaring type of the property. 133 /// </summary> 134 /// <returns></returns> 87 135 public Type GetPropertyDeclaringBaseType() { 88 136 return ((PropertyInfo)MemberInfo).GetGetMethod(true).GetBaseDefinition().DeclaringType; … … 90 138 } 91 139 92 sealed class TypeQuery {140 private sealed class TypeQuery { 93 141 public Type Type { get; private set; } 94 142 public bool Inherited { get; private set; } … … 99 147 } 100 148 101 sealed class MemberCache : Dictionary<TypeQuery, IEnumerable<StorableMemberInfo>> { }149 private sealed class MemberCache : Dictionary<TypeQuery, IEnumerable<StorableMemberInfo>> { } 102 150 103 151 private static MemberCache memberCache = new MemberCache(); … … 106 154 /// <summary> 107 155 /// Get all fields and properties of a class that have the 108 /// <code>[Storable]</code> attribute set. 109 /// </summary> 156 /// <c>[Storable]</c> attribute set. 157 /// </summary> 158 /// <param name="type">The type.</param> 159 /// <returns>An enumerable of StorableMemberInfos.</returns> 110 160 public static IEnumerable<StorableMemberInfo> GetStorableMembers(Type type) { 111 161 return GetStorableMembers(type, true); … … 114 164 /// <summary> 115 165 /// Get all fields and properties of a class that have the 116 /// <code>[Storable]</code> attribute set. 117 /// </summary> 118 /// <param name="inherited">should storable members from base classes be included</param> 166 /// <c>[Storable]</c> attribute set. 167 /// </summary> 168 /// <param name="type">The type.</param> 169 /// <param name="inherited">should storable members from base classes be included</param> 170 /// <returns>An enumerable of StorableMemberInfos</returns> 119 171 public static IEnumerable<StorableMemberInfo> GetStorableMembers(Type type, bool inherited) { 120 172 lock (memberCache) { … … 144 196 /// Get the associated accessors for all storable memebrs. 145 197 /// </summary> 146 /// <param name="obj"> </param>147 /// <returns> </returns>198 /// <param name="obj">The object</param> 199 /// <returns>An enumerable of storable accessors.</returns> 148 200 public static IEnumerable<DataMemberAccessor> GetStorableAccessors(object obj) { 149 201 foreach (var memberInfo in GetStorableMembers(obj.GetType()))
Note: See TracChangeset
for help on using the changeset viewer.