Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence/3.3/Default/CompositeSerializers/Storable/StorableMemberInfo.cs @ 3606

Last change on this file since 3606 was 3029, checked in by epitzer, 15 years ago

add support for automatic serialization of fields and properties (#548)

File size: 1.4 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using HeuristicLab.Persistence.Interfaces;
5using HeuristicLab.Persistence.Core;
6using System.Reflection;
7using HeuristicLab.Persistence.Auxiliary;
8using System.Text;
9
10namespace HeuristicLab.Persistence.Default.CompositeSerializers.Storable {
11
12  internal sealed class StorableMemberInfo {
13    public MemberInfo MemberInfo { get; private set; }
14    public string DisentangledName { get; private set; }
15    public object DefaultValue { get; private set; }
16    public string FullyQualifiedMemberName {
17      get {
18        return new StringBuilder()
19          .Append(MemberInfo.ReflectedType.FullName)
20          .Append('.')
21          .Append(MemberInfo.Name)
22          .ToString();
23      }
24    }
25    public StorableMemberInfo(StorableAttribute attribute, MemberInfo memberInfo) {
26      DisentangledName = attribute.Name;
27      DefaultValue = attribute.DefaultValue;
28      MemberInfo = memberInfo;
29    }
30    public StorableMemberInfo(MemberInfo memberInfo) {
31      MemberInfo = memberInfo;
32    }
33    public void SetDisentangledName(string name) {
34      if (DisentangledName == null)
35        DisentangledName = name;
36    }
37    public Type GetPropertyDeclaringBaseType() {
38      return ((PropertyInfo)MemberInfo).GetGetMethod(true).GetBaseDefinition().DeclaringType;
39    }
40  } 
41}
Note: See TracBrowser for help on using the repository browser.