Changeset 1314
- Timestamp:
- 03/09/09 12:44:51 (16 years ago)
- Location:
- branches/New Persistence Exploration/Persistence/Persistence
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/New Persistence Exploration/Persistence/Persistence/CompoundSerializers.cs
r1313 r1314 5 5 namespace Persistence { 6 6 7 public interface IC ustomSerializer {7 public interface ICompoundSerializer { 8 8 bool CanSerialize(Type type); 9 9 IEnumerable Serialize(object o); … … 11 11 } 12 12 13 public class EnumerableSerializer : IC ustomSerializer {13 public class EnumerableSerializer : ICompoundSerializer { 14 14 public bool CanSerialize(Type type) { 15 15 if (type.GetInterface("IEnumerable") == null) … … 36 36 } 37 37 38 public class ArraySerializer : IC ustomSerializer {38 public class ArraySerializer : ICompoundSerializer { 39 39 40 40 public bool CanSerialize(Type type) { -
branches/New Persistence Exploration/Persistence/Persistence/DeSerializer.cs
r1281 r1314 62 62 63 63 private Dictionary<Type, IPrimitiveSerializer> primitiveSerializers; 64 private List<IC ustomSerializer> customSerializers;64 private List<ICompoundSerializer> customSerializers; 65 65 66 66 delegate void Thunk(); … … 69 69 public DeSerializer( 70 70 IEnumerable<IPrimitiveSerializer> primitiveSerializers, 71 IEnumerable<IC ustomSerializer> customSerializers) {71 IEnumerable<ICompoundSerializer> customSerializers) { 72 72 id2obj = new Dictionary<int, object>(); 73 73 compositeStack = new Stack<IAccessibleObject>(); … … 82 82 this.primitiveSerializers.Add(ps.Type, ps); 83 83 } 84 this.customSerializers = new List<IC ustomSerializer>(customSerializers);84 this.customSerializers = new List<ICompoundSerializer>(customSerializers); 85 85 this.finalFixes = new List<Thunk>(); 86 86 } … … 112 112 private void CompositeEndHandler(IParseToken token) { 113 113 CompositeEnd end = (CompositeEnd)token; 114 IC ustomSerializer customSerializer = this.FindCustomSerializer(end.Type);114 ICompoundSerializer customSerializer = this.FindCustomSerializer(end.Type); 115 115 if (customSerializer != null) { 116 116 CustomObject customObject = (CustomObject)compositeStack.Pop(); … … 124 124 } 125 125 } 126 private IC ustomSerializer FindCustomSerializer(Type type) {127 foreach (IC ustomSerializer serializer in customSerializers) {126 private ICompoundSerializer FindCustomSerializer(Type type) { 127 foreach (ICompoundSerializer serializer in customSerializers) { 128 128 if (serializer.CanSerialize(type)) 129 129 return serializer; -
branches/New Persistence Exploration/Persistence/Persistence/NewSerializationTest.cs
r1312 r1314 60 60 new Double2XmlSerializer(), 61 61 }, 62 new IC ustomSerializer[] {62 new ICompoundSerializer[] { 63 63 new ArraySerializer(), 64 64 new EnumerableSerializer() }); -
branches/New Persistence Exploration/Persistence/Persistence/Serializer.cs
r1280 r1314 11 11 private Dictionary<object, int> obj2id; 12 12 private Dictionary<Type, IPrimitiveSerializer> primitiveSerializers; 13 private List<IC ustomSerializer> customSerializers;13 private List<ICompoundSerializer> customSerializers; 14 14 15 15 public Serializer(object obj, IEnumerable<IPrimitiveSerializer> primitiveSerializers) : … … 23 23 this.primitiveSerializers.Add(serializer.Type, serializer); 24 24 } 25 this.customSerializers = new List<IC ustomSerializer>();25 this.customSerializers = new List<ICompoundSerializer>(); 26 26 customSerializers.Add(new EnumerableSerializer()); 27 27 customSerializers.Add(new ArraySerializer()); … … 54 54 this.obj2id.Add(value, id); 55 55 yield return new BeginToken(accessor, id); 56 IC ustomSerializer customSerializer = this.FindCustomSerializer(value.GetType());56 ICompoundSerializer customSerializer = this.FindCustomSerializer(value.GetType()); 57 57 if (customSerializer != null) { 58 58 foreach (object obj in customSerializer.Serialize(value)) { … … 73 73 } 74 74 75 private IC ustomSerializer FindCustomSerializer(Type type) {76 foreach (IC ustomSerializer s in customSerializers) {75 private ICompoundSerializer FindCustomSerializer(Type type) { 76 foreach (ICompoundSerializer s in customSerializers) { 77 77 if (s.CanSerialize(type)) 78 78 return s;
Note: See TracChangeset
for help on using the changeset viewer.