Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Persistence.Test/StorableAttributeTests.cs @ 1463

Last change on this file since 1463 was 1454, checked in by epitzer, 16 years ago

merge persistence exploration branch into trunk as HL plugin. (#506)

File size: 964 bytes
Line 
1using System;
2using System.Collections.Generic;
3using HeuristicLab.Persistence.Core;
4
5namespace HeuristicLab.Persistence.Test {
6
7  class TestClass {
8
9    [Storable(Name="TestProperty", DefaultValue=12)]
10    public object o;
11
12    [Storable]
13    public int x = 2;
14
15    public int y;
16
17  }
18
19  class AttributeTest {
20
21    static void Main() {
22      TestClass t = new TestClass();
23      Dictionary<string, DataMemberAccessor> accessors = StorableAttribute.GetAutostorableAccessors(t);
24      foreach ( KeyValuePair<string, DataMemberAccessor> pair in accessors ) {
25        Console.WriteLine(pair.Key + ": " + pair.Value);
26      }
27      t.o = new Object();
28      t.x = 12;
29      t.y = 312890;
30      accessors["o"].Set(null);
31      accessors["x"].Set(123);
32      try {
33        accessors["y"].Set(0);
34        throw new InvalidOperationException();
35      } catch ( KeyNotFoundException ) { }
36      Console.ReadLine();
37    }
38
39  }
40
41}
Note: See TracBrowser for help on using the repository browser.