Changeset 1555
- Timestamp:
- 04/14/09 14:26:45 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence.Test/StorableAttributeTests.cs
r1454 r1555 21 21 static void Main() { 22 22 TestClass t = new TestClass(); 23 Dictionary<string, DataMemberAccessor> accessors = StorableAttribute.Get AutostorableAccessors(t);23 Dictionary<string, DataMemberAccessor> accessors = StorableAttribute.GetStorableAccessors(t); 24 24 foreach ( KeyValuePair<string, DataMemberAccessor> pair in accessors ) { 25 25 Console.WriteLine(pair.Key + ": " + pair.Value); -
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 } -
trunk/sources/HeuristicLab.Persistence/3.3/Default/Decomposers/StorableDecomposer.cs
r1553 r1555 15 15 public bool CanDecompose(Type type) { 16 16 return StorableAttribute.GetStorableMembers(type, false).Count() > 0 || 17 EmptyStorableClassAttribute.IsEmp yStorable(type);17 EmptyStorableClassAttribute.IsEmptyStorable(type); 18 18 19 19 } … … 24 24 25 25 public IEnumerable<Tag> Decompose(object obj) { 26 foreach (var mapping in StorableAttribute.Get AutostorableAccessors(obj)) {26 foreach (var mapping in StorableAttribute.GetStorableAccessors(obj)) { 27 27 yield return new Tag(mapping.Key, mapping.Value.Get()); 28 28 } … … 39 39 memberDict.Add(iter.Current.Name, iter.Current); 40 40 } 41 foreach (var mapping in StorableAttribute.Get AutostorableAccessors(instance)) {41 foreach (var mapping in StorableAttribute.GetStorableAccessors(instance)) { 42 42 if (memberDict.ContainsKey(mapping.Key)) { 43 43 mapping.Value.Set(memberDict[mapping.Key].Value); -
trunk/sources/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj
r1554 r1555 94 94 <ItemGroup> 95 95 <Compile Include="Core\Configuration.cs" /> 96 <Compile Include="Core\EmptyStorableClassAttribute.cs" /> 97 <Compile Include="Core\TypeExtensions.cs" /> 96 98 <Compile Include="Core\TypeMapping.cs" /> 97 99 <Compile Include="Core\TypeStringBuilder.cs" /> … … 112 114 <Compile Include="Core\DataMemberAccessor.cs" /> 113 115 <Compile Include="Default\Xml\Compact\IntList2XmlFormatter.cs" /> 114 <Compile Include="Default\Xml\Primitive\Double2XmlFormatter Base.cs" />115 <Compile Include="Default\Xml\Primitive\Decimal2XmlFormatter Base.cs" />116 <Compile Include="Default\Xml\Primitive\Float2XmlFormatter Base.cs" />116 <Compile Include="Default\Xml\Primitive\Double2XmlFormatter.cs" /> 117 <Compile Include="Default\Xml\Primitive\Decimal2XmlFormatter.cs" /> 118 <Compile Include="Default\Xml\Primitive\Float2XmlFormatter.cs" /> 117 119 <Compile Include="Default\Xml\Primitive\UInt2XmlFormatter.cs" /> 118 120 <Compile Include="Default\Xml\Primitive\Long2XmlFormatter.cs" />
Note: See TracChangeset
for help on using the changeset viewer.