internal object OnCreateSubObjectDelegate(object dataSource, MappingEventArgs args, ref bool useDefaultObject) { object result = null; if (CreateSubObject != null) { result = CreateSubObject(dataSource, args, ref useDefaultObject); } return(result); }
private static void SetValueToObject(ORMappingItem item, object graph, object data, object row, DataToObjectDeligations dod) { if (string.IsNullOrEmpty(item.SubClassPropertyName)) { SetMemberValueToObject(item.MemberInfo, graph, data); } else { if (graph != null) { MemberInfo mi = graph.GetType().GetProperty(item.PropertyName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (mi == null) { mi = graph.GetType().GetField(item.PropertyName, BindingFlags.Instance | BindingFlags.Public); } if (mi != null) { object subGraph = GetMemberValueFromObject(mi, graph); if (subGraph == null) { bool useDefaultObject = true; if (dod != null) { MappingEventArgs args = new MappingEventArgs(); args.DataFieldName = item.DataFieldName; args.PropertyName = item.PropertyName; args.Graph = graph; subGraph = dod.OnCreateSubObjectDelegate(row, args, ref useDefaultObject); } if (useDefaultObject) { if (string.IsNullOrEmpty(item.SubClassTypeDescription) == false) { subGraph = TypeCreator.CreateInstance(item.SubClassTypeDescription); } else { subGraph = Activator.CreateInstance(GetRealType(mi), true); } } SetMemberValueToObject(item.MemberInfo, subGraph, data); SetMemberValueToObject(mi, graph, subGraph); } else { SetMemberValueToObject(item.MemberInfo, subGraph, data); } } } } }