Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/25/09 17:16:32 (15 years ago)
Author:
epitzer
Message:

Implement persistence of storables as decomposer. (#506)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/New Persistence Exploration/Persistence/Persistence/Core/DataMemberAccessor.cs

    r1360 r1419  
    1212    public readonly Getter Get;
    1313    public readonly Setter Set;
    14     public readonly string Name;
    15     public readonly Type Type;
     14    public readonly string Name;   
    1615    public readonly object DefaultValue;
    1716
     
    2322        FieldInfo fieldInfo = (FieldInfo)memberInfo;
    2423        Get = () => fieldInfo.GetValue(obj);
    25         Set = value => fieldInfo.SetValue(obj, value);
    26         Type = fieldInfo.FieldType;
     24        Set = value => fieldInfo.SetValue(obj, value);       
    2725      } else if (memberInfo.MemberType == MemberTypes.Property) {
    2826        PropertyInfo propertyInfo = (PropertyInfo)memberInfo;
     
    3230        }
    3331        Get = () => propertyInfo.GetValue(obj, null);
    34         Set = value => propertyInfo.SetValue(obj, value, null);
    35         Type = propertyInfo.PropertyType;
     32        Set = value => propertyInfo.SetValue(obj, value, null);       
    3633      } else {
    3734        throw new NotSupportedException(
     
    4340
    4441    public DataMemberAccessor(
    45         string name, Type type, object defaultValue,
     42        string name, object defaultValue,
    4643        Getter getter, Setter setter) {
    47       Name = name;
    48       Type = type;
     44      Name = name;     
    4945      DefaultValue = defaultValue;
    5046      Get = getter;
     
    5349
    5450    public DataMemberAccessor(object o) {
    55       Name = null;
    56       Type = o.GetType();
     51      Name = null;     
    5752      DefaultValue = null;
    5853      Get = () => o;
     
    6055    }
    6156
     57    public DataMemberAccessor(object o, string name) {
     58      Name = name;     
     59      DefaultValue = null;
     60      Get = () => o;
     61      Set = null;
     62    }
     63
     64
    6265    public override string ToString() {
    63       return String.Format("DataMember({0}, {1}, {2}, {3}, {4})",
     66      return String.Format("DataMember({0}, {2}, {3}, {4})",
    6467        Name,
    65         Type == null ? "<null>" : Type.FullName,
    6668        DefaultValue ?? "<null>",
    6769        Get.Method, Set.Method);
Note: See TracChangeset for help on using the changeset viewer.