Changeset 1331 for branches/New Persistence Exploration/Persistence
- Timestamp:
- 03/12/09 13:49:56 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence
- Property svn:ignore
-
old new 3 3 *.suo 4 4 _ReSharper.Persistence 5 Persistence.4.1.resharper.user
-
- Property svn:ignore
-
branches/New Persistence Exploration/Persistence/Persistence/DeSerializer.cs
r1330 r1331 4 4 public class DeSerializer { 5 5 6 class ParentReference { 7 } 6 struct ParentReference { } 8 7 9 8 delegate void Setter(object value); -
branches/New Persistence Exploration/Persistence/Persistence/StorableAttribute.cs
r1330 r1331 19 19 BindingFlags.Public | 20 20 BindingFlags.NonPublic; 21 22 23 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> GetStorableMembers(object obj) { 24 foreach (MemberInfo memberInfo in obj.GetType().GetMembers(instanceMembers)) { 21 22 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> GetStorableMembers(Type type) { 23 return GetStorableMembers(type, true); 24 } 25 26 public static IEnumerable<KeyValuePair<StorableAttribute, MemberInfo>> 27 GetStorableMembers(Type type, bool inherited) { 28 if (type.BaseType != null) 29 foreach ( var pair in GetStorableMembers(type.BaseType) ) 30 yield return pair; 31 foreach (MemberInfo memberInfo in type.GetMembers(instanceMembers)) { 25 32 foreach (object attribute in memberInfo.GetCustomAttributes(false)) { 26 33 StorableAttribute storableAttribute = … … 36 43 Dictionary<string, DataMemberAccessor> storableAccessors = 37 44 new Dictionary<string, DataMemberAccessor>(); 38 foreach (KeyValuePair<StorableAttribute, MemberInfo> pair in GetStorableMembers(obj )) {45 foreach (KeyValuePair<StorableAttribute, MemberInfo> pair in GetStorableMembers(obj.GetType())) { 39 46 storableAccessors.Add(pair.Value.Name, 40 47 new DataMemberAccessor(pair.Value, pair.Key, obj)); -
branches/New Persistence Exploration/Persistence/Persistence/Test/NewSerializationTest.cs
r1329 r1331 3 3 using System.Collections; 4 4 using System.IO; 5 using System.Reflection; 5 6 6 7 namespace Persistence.Test { 7 8 8 public class Root { 9 public class RootBase { 10 [Storable] private string baseString = "Serial"; 11 } 12 13 public class Root : RootBase { 9 14 [Storable] 10 15 public int[] i = new[] { 3, 4, 5, 6 }; … … 240 245 } 241 246 247 public class Base { 248 [Storable] private int baseInt = 3; 249 } 250 251 public class Derived: Base { 252 [Storable] private int derivedInt = 5; 253 } 254 242 255 public static void Main() { 256 int[] i = {1, 2, 3}; 257 object o = i; 258 Type type = o.GetType().BaseType.BaseType; 259 foreach (MemberInfo mi in type.GetMembers(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic )) { 260 if ( mi.MemberType == MemberTypes.Field || mi.MemberType == MemberTypes.Property ) 261 Console.WriteLine(mi.Name); 262 } 243 263 Test1(); 244 264 //Test2();
Note: See TracChangeset
for help on using the changeset viewer.