internal static MediaDataReader <MediaInfo> SelectMedia <T>(ForeachFunc <T> func, T param, SelectArguments arguments) { using (var filter = QueryArguments.ToNativeHandle(arguments)) { var items = new List <MediaInfo>(); Exception exception = null; func(param, filter, (mediaInfoHandle, _) => { try { items.Add(MediaInfo.FromHandle(mediaInfoHandle)); return(true); } catch (Exception e) { exception = e; return(false); } }).ThrowIfError("Failed to query"); if (exception != null) { throw exception; } return(new MediaDataReader <MediaInfo>(items)); } }
internal static MediaDataReader <TRecord> Select <TRecord>(SelectArguments arguments, ForeachFunc foreachFunc, Func <IntPtr, TRecord> factoryFunc) { using (var filter = QueryArguments.ToNativeHandle(arguments)) { Exception caught = null; var items = new List <TRecord>(); foreachFunc(filter, (itemHandle, _) => { try { items.Add(factoryFunc(itemHandle)); return(true); } catch (Exception e) { caught = e; return(false); } }).ThrowIfError("Failed to execute query"); if (caught != null) { throw caught; } return(new MediaDataReader <TRecord>(items)); } }
internal static IntPtr SelectScalar(ForeachFunc foreachFunc, string filterExpression, CloneFunc cloneFunc) { using (var filter = QueryArguments.CreateNativeHandle(filterExpression)) { IntPtr handle = IntPtr.Zero; foreachFunc(filter, (itemHandle, _) => { cloneFunc(out handle, itemHandle); return(false); }).ThrowIfError("Failed to execute query"); return(handle); } }
private void Foreach(ForeachFunc func) { }