Changeset 1555 for trunk/sources/HeuristicLab.Persistence/3.3/Core
- Timestamp:
- 04/14/09 14:26:45 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Persistence/3.3/Core
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/3.3/Core/StorableAttribute.cs
r1455 r1555 4 4 5 5 namespace HeuristicLab.Persistence.Core { 6 7 8 [AttributeUsage(9 AttributeTargets.Class,10 AllowMultiple=false,11 Inherited=false)]12 public class EmptyStorableClassAttribute : Attribute {13 private static readonly Dictionary<Type, bool> emptyTypeInfo = new Dictionary<Type, bool>();14 public static bool IsEmpyStorable(Type type) {15 if (emptyTypeInfo.ContainsKey(type))16 return emptyTypeInfo[type];17 foreach (var attribute in type.GetCustomAttributes(false)) {18 EmptyStorableClassAttribute empty = attribute as EmptyStorableClassAttribute;19 if (empty != null) {20 emptyTypeInfo.Add(type, true);21 return true;22 }23 }24 int nFields = 0;25 foreach ( MemberInfo memberInfo in type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ) {26 if (memberInfo.MemberType == MemberTypes.Field ||27 memberInfo.MemberType == MemberTypes.Property)28 nFields += 1;29 }30 if (nFields == 0) {31 emptyTypeInfo.Add(type, true);32 return true;33 }34 emptyTypeInfo.Add(type, false);35 return false;36 }37 }38 6 39 7 [AttributeUsage( … … 72 40 } 73 41 74 public static Dictionary<string, DataMemberAccessor> Get AutostorableAccessors(object obj) {42 public static Dictionary<string, DataMemberAccessor> GetStorableAccessors(object obj) { 75 43 Dictionary<string, DataMemberAccessor> storableAccessors = 76 44 new Dictionary<string, DataMemberAccessor>(); -
trunk/sources/HeuristicLab.Persistence/3.3/Core/TypeStringBuilder.cs
r1519 r1555 4 4 namespace HeuristicLab.Persistence.Core { 5 5 6 publicstatic class TypeStringBuilder {6 internal static class TypeStringBuilder { 7 7 8 privatestatic void BuildDeclaringTypeChain(Type type, StringBuilder sb) {8 internal static void BuildDeclaringTypeChain(Type type, StringBuilder sb) { 9 9 if ( type.DeclaringType != null ) { 10 10 BuildDeclaringTypeChain(type.DeclaringType, sb); … … 13 13 } 14 14 15 privatestatic void BuildVersionInvariantName(Type type, StringBuilder sb) {15 internal static void BuildVersionInvariantName(Type type, StringBuilder sb) { 16 16 sb.Append(type.Namespace).Append('.'); 17 17 BuildDeclaringTypeChain(type, sb); … … 32 32 } 33 33 34 public static string VersionInvariantName(this Type type) { 35 StringBuilder sb = new StringBuilder(); 36 BuildVersionInvariantName(type, sb); 37 return sb.ToString(); 38 } 39 } 34 } 40 35 41 36 }
Note: See TracChangeset
for help on using the changeset viewer.