Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 1612 was 1566, checked in by epitzer, 15 years ago

Format white space. (Ctrl-K, Ctrl-D) (#548)

File size: 960 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.GetStorableAccessors(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.