Free cookie consent management tool by TermsFeed Policy Generator

source: branches/New Persistence Exploration/Persistence/Persistence/StorableAttributeTests.cs @ 1313

Last change on this file since 1313 was 1264, checked in by epitzer, 15 years ago

Full serialization from object tree to XML. No de-serialization yet. (#506)

File size: 939 bytes
Line 
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace Persistence {
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.ToString());
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.