protected VisitResult VisitProjection(ProjectionOperation operation) { var source = Visit(operation.Source); if (source.ResultSchema.Kind != SchemaNodeKind.Collection) { throw new InvalidOperationException("Can only use projection operations on collections"); } var parameter = Expression.Parameter(source.ElementType, operation.ParameterName); using (CreateScope(new[] { new FunctionScopeVariable(operation.ParameterName, ((SchemaNodeCollection)source.ResultSchema).ElementSchema, parameter) })) { var projection = Visit(operation.Projection); var lambda = Expression.Lambda(projection.Expression, new[] { parameter }); var arguments = new[] { source.Expression, Expression.Quote(lambda) }; return(new VisitResult { ResultSchema = new SchemaNodeCollection(projection.ResultSchema), Expression = Expression.Call( null, typeof(Queryable).GetMethod("Select", arguments.Select(expr => expr.Type).ToArray()), arguments), ElementType = projection.Expression.Type, }); } }
/// <summary> /// Adds new file to the report /// </summary> /// <param name="filename">Filename</param> /// <param name="projection">Projection name</param> /// <param name="operation">Operation that was applied to the file</param> /// <param name="newName">The new name of the file (in case of reprojection)</param> public void AddFile(string filename, string projection, ProjectionOperation operation, string newName) { string s = operation.ToString(); switch (operation) { case ProjectionOperation.AbsenceIgnored: s = "Absence ignored"; break; case ProjectionOperation.MismatchIgnored: s = "Mismatch ignored"; break; case ProjectionOperation.FailedToReproject: s = "Failed to reproject"; break; } var item = listView1.Items.Add(Path.GetFileName(filename)); item.SubItems.Add(projection == "" ? "none" : projection); item.SubItems.Add(s); item.SubItems.Add(Path.GetFileName(newName)); if (operation == ProjectionOperation.Skipped || operation == ProjectionOperation.FailedToReproject) { item.SubItems.Add(MapConfig.GdalReprojectionErrorMsg); } else { item.SubItems.Add(""); } listView1.Refresh(); ListViewHelper.AutoResizeColumns(listView1); Application.DoEvents(); }