Skip to content

Commit 2045532

Browse files
committed
Accept nested objects
1 parent 30ab22a commit 2045532

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

CS/NonPersistentObjectsDemo.Module/DataStoreMapper.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ private List<object> PhaseTwo(DataStoreMapping mapping, Type objectType, SelectS
9191
private void PhaseThree(DataStoreMapping mapping, List<object> objects, SelectStatementResult result) {
9292
for(int i = 0; i < objects.Count; i++) {
9393
mapping.Load(objects[i], result.Rows[i].Values, objectMap);
94+
objectMap.Accept(objects[i]);
9495
}
9596
}
9697
public IList<object> LoadObjects(Type objectType, CriteriaOperator criteria) {

CS/NonPersistentObjectsDemo.Module/Module.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private void Application_SetupComplete(object sender, EventArgs e) {
3939
nonPersistentObjectSpaceHelper = new NonPersistentObjectSpaceHelper((XafApplication)sender, typeof(BaseObject));
4040
nonPersistentObjectSpaceHelper.AdapterCreators.Add(npos => {
4141
var types = new Type[] { typeof(Account), typeof(Message) };
42-
var map = new ObjectMap(types);
42+
var map = new ObjectMap(npos, types);
4343
new TransientNonPersistentObjectAdapter(npos, map, new PostOfficeFactory(map));
4444
});
4545
}

CS/NonPersistentObjectsDemo.Module/TransientNonPersistentObjectAdapter.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,9 @@ private void DynamicCollection_FetchObjects(object sender, FetchObjectsEventArgs
105105

106106
public class ObjectMap {
107107
private Dictionary<Type, Dictionary<Object, Object>> typeMap;
108-
public ObjectMap(params Type[] types) {
108+
private NonPersistentObjectSpace objectSpace;
109+
public ObjectMap(NonPersistentObjectSpace objectSpace, params Type[] types) {
110+
this.objectSpace = objectSpace;
109111
this.typeMap = new Dictionary<Type, Dictionary<object, object>>();
110112
foreach(var type in types) {
111113
typeMap.Add(type, new Dictionary<object, object>());
@@ -145,5 +147,8 @@ public void Add(Type type, Object key, Object obj) {
145147
objectMap.Add(key, obj);
146148
}
147149
}
150+
public void Accept(Object obj) {
151+
objectSpace.GetObject(obj);
152+
}
148153
}
149154
}

0 commit comments

Comments
 (0)