Last change
on this file since 3579 was
3029,
checked in by epitzer, 14 years ago
|
add support for automatic serialization of fields and properties (#548)
|
File size:
1.4 KB
|
Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using HeuristicLab.Persistence.Interfaces;
|
---|
5 | using HeuristicLab.Persistence.Core;
|
---|
6 | using System.Reflection;
|
---|
7 | using HeuristicLab.Persistence.Auxiliary;
|
---|
8 | using System.Text;
|
---|
9 |
|
---|
10 | namespace 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.