- Timestamp:
- 03/14/10 00:42:28 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/DataMemberAccessor.cs
r3004 r3016 12 12 public class DataMemberAccessor { 13 13 14 /// <summary> 15 /// The function to get the value of the data member. 16 /// </summary> 14 17 public readonly Func<object> Get; 18 19 /// <summary> 20 /// The function to set the value of the data member. 21 /// </summary> 15 22 public readonly Action<object> Set; 23 24 /// <summary> 25 /// The name of the data member. 26 /// </summary> 16 27 public readonly string Name; 28 29 /// <summary> 30 /// The default value of the data member, can remain <c>null</c> 31 /// if no default value. If left null, this will also leave the 32 /// default value for value types (e.g. 0 for <c>int</c>). 33 /// </summary> 17 34 public readonly object DefaultValue; 18 35 19 36 20 37 /// <summary> 21 /// Create a DataMemberAccessor from a FieldInfo or PropertyInfo for the give object. 38 /// Create a <see cref="DataMemberAccessor"/> from a FieldInfo or 39 /// PropertyInfo for the give object. 22 40 /// </summary> 41 /// <param name="memberInfo">The member info.</param> 42 /// <param name="name">The name.</param> 43 /// <param name="defaultvalue">The defaultvalue.</param> 44 /// <param name="obj">The object.</param> 23 45 public DataMemberAccessor(MemberInfo memberInfo, string name, object defaultvalue, object obj) { 24 46 Name = name; … … 45 67 /// Wrap existing getter and setter functions. 46 68 /// </summary> 69 /// <param name="name">The name.</param> 70 /// <param name="defaultValue">The default value.</param> 71 /// <param name="getter">The getter.</param> 72 /// <param name="setter">The setter.</param> 47 73 public DataMemberAccessor(string name, object defaultValue, 48 74 Func<object> getter, Action<object> setter) { … … 52 78 Set = setter; 53 79 } 54 80 55 81 /// <summary> 56 82 /// Create an empty accessor that just encapsulates an object 57 83 /// without access. 58 84 /// </summary> 85 /// <param name="o">The object</param> 59 86 public DataMemberAccessor(object o) { 60 87 Name = null; … … 68 95 /// without access. 69 96 /// </summary> 97 /// <param name="o">The object</param> 98 /// <param name="name">The object's name.</param> 70 99 public DataMemberAccessor(object o, string name) { 71 100 Name = name; … … 75 104 } 76 105 106 /// <summary> 107 /// Returns a <see cref="System.String"/> that represents this instance. 108 /// </summary> 109 /// <returns> 110 /// A <see cref="System.String"/> that represents this instance. 111 /// </returns> 77 112 public override string ToString() { 78 113 return String.Format("DataMemberAccessor({0}, {1}, {2}, {3})", -
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())) -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableClassAttribute.cs
r2994 r3016 48 48 49 49 /// <summary> 50 /// Mark a class to be considered by the <c ode>StorableSerializer</code>.50 /// Mark a class to be considered by the <c>StorableSerializer</c>. 51 51 /// </summary> 52 52 [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] … … 60 60 61 61 /// <summary> 62 /// Mark a class to be serialize by the <c ode>StorableSerizlier</code>62 /// Mark a class to be serialize by the <c>StorableSerizlier</c> 63 63 /// </summary> 64 64 public StorableClassAttribute(StorableClassType type) { … … 70 70 /// or conatins proper parameterization through the storable attribute. 71 71 /// </summary> 72 /// <param name="type"></param> 73 /// <param name="recusrive"></param> 74 /// <returns></returns> 72 /// <param name="type">The type.</param> 73 /// <param name="recusrive">if set to <c>true</c> recusrively checks class hierarchy.</param> 74 /// <returns> 75 /// <c>true</c> if the specified type is a storable type; otherwise, <c>false</c>. 76 /// </returns> 75 77 public static bool IsStorableType(Type type, bool recusrive) { 76 78 if (IsEmptyType(type, recusrive)) … … 91 93 92 94 95 /// <summary> 96 /// Determines whether the specified type has no fields or properties except 97 /// readonly properties or constant fields. 98 /// </summary> 99 /// <param name="type">The type.</param> 100 /// <param name="recursive">if set to <c>true</c> recursively check class hierarchy.</param> 101 /// <returns> 102 /// <c>true</c> if the specified type is empty; otherwise, <c>false</c>. 103 /// </returns> 93 104 public static bool IsEmptyType(Type type, bool recursive) { 94 105 foreach (MemberInfo memberInfo in type.GetMembers(allDeclaredMembers)) { -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableConstructorAttribute.cs
r2994 r3016 11 11 /// <summary> 12 12 /// Indicate that this constructor should be used instead of the default constructor 13 /// when the <c ode>StorableSerializer</code> instantiates this class during13 /// when the <c>StorableSerializer</c> instantiates this class during 14 14 /// deserialization. 15 15 /// 16 /// The constructor must take exactly one <c ode>bool</code> argument that will be17 /// set to <c ode>true</code> during deserialization.16 /// The constructor must take exactly one <c>bool</c> argument that will be 17 /// set to <c>true</c> during deserialization. 18 18 /// </summary> 19 19 [AttributeUsage(AttributeTargets.Constructor, Inherited = false, AllowMultiple = false)] … … 28 28 29 29 /// <summary> 30 /// Get a designated storable constructor for a type or <code>null</code>. 31 /// </summary> 30 /// Get a designated storable constructor for a type or <c>null</c>. 31 /// </summary> 32 /// <param name="type">The type.</param> 33 /// <returns>The <see cref="ConstructorInfo"/> of the storable constructor or <c>null</c></returns> 32 34 public static ConstructorInfo GetStorableConstructor(Type type) { 33 35 lock (constructorCache) { -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableHookAttribute.cs
r3010 r3016 16 16 /// <summary> 17 17 /// Mark methods that should be called at certain times during 18 /// serialization/deserialization by the <c ode>StorableSerializer</code>.18 /// serialization/deserialization by the <c>StorableSerializer</c>. 19 19 /// </summary> 20 20 [AttributeUsage(AttributeTargets.Method, Inherited = false, AllowMultiple = true)] … … 32 32 33 33 private readonly HookType hookType; 34 /// <summary> 35 /// Gets the type of the hook. 36 /// </summary> 37 /// <value>The type of the hook.</value> 34 38 public HookType HookType { 35 39 get { return hookType; } … … 38 42 39 43 /// <summary> 40 /// Mark method as <c ode>StorableSerializer</code> hook to be run41 /// at the <c ode>HookType</code> time.44 /// Mark method as <c>StorableSerializer</c> hook to be run 45 /// at the <c>HookType</c> time. 42 46 /// </summary> 43 /// <param name="hookType"> </param>47 /// <param name="hookType">Type of the hook.</param> 44 48 public StorableHookAttribute(HookType hookType) { 45 49 this.hookType = hookType; … … 56 60 57 61 /// <summary> 58 /// Invoke <code>hookType</code> hook on <code>obj</code>. 59 /// </summary> 62 /// Invoke <c>hookType</c> hook on <c>obj</c>. 63 /// </summary> 64 /// <param name="hookType">Type of the hook.</param> 65 /// <param name="obj">The object.</param> 60 66 public static void InvokeHook(HookType hookType, object obj) { 61 67 if (obj == null) -
trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableSerializer.cs
r2994 r3016 11 11 /// <summary> 12 12 /// Intended for serialization of all custom classes. Classes should have the 13 /// <c ode>[StorableClass(StorableClassType.Empty)]</code> attribute set and a serialization mode set.13 /// <c>[StorableClass(StorableClassType.Empty)]</c> attribute set and a serialization mode set. 14 14 /// Optionally selected fields and properties can be marked with the 15 /// <c ode>[Storable]</code> attribute.15 /// <c>[Storable]</c> attribute. 16 16 /// </summary> 17 17 [StorableClass(StorableClassType.Empty)]
Note: See TracChangeset
for help on using the changeset viewer.