public static void AllChannelsAreInMemory(Type type, object settings) { type.GetProperties().Where(x => x.CanWrite && x.PropertyType == typeof(Uri)).Each(prop => { var accessor = new SingleProperty(prop); var uri = GetUriForProperty(accessor); accessor.SetValue(settings, uri); }); }
private void populateDTOWithRelatedDTOs(ClarifyGenericMapEntry parentGenericMap, ClarifyDataRow parentRecord, object parentDto) { var childMapsForChildDtos = parentGenericMap.ChildGenericMaps.Where(child => parentDto.GetType() != child.Model.ModelType); foreach (var childMap in childMapsForChildDtos) { var parentProperty = new SingleProperty(childMap.Model.ParentProperty); var childModelType = childMap.Model.ModelType; if (typeof(IEnumerable).IsAssignableFrom(parentProperty.PropertyType)) { var propertyDTOs = new ArrayList(); foreach (var childRecord in parentRecord.RelatedRows(childMap.ClarifyGeneric)) { var propertyDTO = FastYetSimpleTypeActivator.CreateInstance(childModelType); populateDTOForGenericRecord(childMap, childRecord, propertyDTO); propertyDTOs.Add(propertyDTO); } parentProperty.SetValue(parentDto, propertyDTOs.ToArray(childModelType)); } else //dto is not enumerable just get the first child row { var relatedChildRows = parentRecord.RelatedRows(childMap.ClarifyGeneric); if (relatedChildRows.Any()) { var propertyDTO = FastYetSimpleTypeActivator.CreateInstance(childModelType); var childRecord = relatedChildRows.First(); populateDTOForGenericRecord(childMap, childRecord, propertyDTO); parentProperty.SetValue(parentDto, propertyDTO); } else { parentProperty.SetValue(parentDto, null); } } } }
public static object ToInMemory(Type type) { var settings = Activator.CreateInstance(type); type.GetProperties().Where(x => x.CanWrite && x.PropertyType == typeof(Uri)).Each(prop => { var accessor = new SingleProperty(prop); var uri = GetUriForProperty(accessor); accessor.SetValue(settings, uri); }); return(settings); }