Updates referencesource to .NET 4.7
[mono.git] / mcs / class / referencesource / System.Data.Entity / System / Data / Objects / ELinq / SpatialMethodCallTranslator.cs
1 //---------------------------------------------------------------------
2 // <copyright file="SpatialMethodCallTranslator" company="Microsoft">
3 //      Copyright (c) Microsoft Corporation.  All rights reserved.
4 // </copyright>
5 //
6 // @owner       willa
7 // @backupOwner Microsoft
8 //--------------------------------------------------------------------------
9 // This file is automatically generated and should not be changed directly.
10 //
11 // See %SDXROOT%\ndp\fx\test\DataEntity\CheckinTests\Metadata\MetadataUnitTests.sln
12 // for the spatial functions unit test that generates this file.
13 //
14 // See %SDXROOT%\ddsuites\src\fx\DataEntity\Spatial\Functions
15 // for the template for this file.
16 //
17 //--------------------------------------------------------------------------
18
19 using System.Collections.Generic;
20 using System.Data.Common.CommandTrees;
21 using System.Diagnostics;
22 using System.Linq;
23 using System.Linq.Expressions;
24 using System.Reflection;
25
26 namespace System.Data.Objects.ELinq
27 {
28     internal sealed partial class ExpressionConverter
29     {
30         private sealed partial class MethodCallTranslator
31                 : TypedTranslator<MethodCallExpression>
32         {
33
34             private sealed class SpatialMethodCallTranslator : CallTranslator
35             {
36                 private static readonly Dictionary<MethodInfo, string> methodFunctionRenames = GetRenamedMethodFunctions();
37
38                 internal SpatialMethodCallTranslator()
39                     : base(GetSupportedMethods())
40                 {
41                 }
42             
43                 private static MethodInfo GetStaticMethod<TResult>(Expression<Func<TResult>> lambda)
44                 {
45                     MethodInfo method = ((MethodCallExpression)lambda.Body).Method;
46                     Debug.Assert(method.IsStatic && method.IsPublic &&
47                                  (method.DeclaringType == typeof(System.Data.Spatial.DbGeography) || method.DeclaringType == typeof(System.Data.Spatial.DbGeometry)),
48                                  "Supported static spatial methods should be public static methods declared by a spatial type");
49                     return method;
50                 }
51
52                 private static MethodInfo GetInstanceMethod<T, TResult>(Expression<Func<T, TResult>> lambda)
53                 {
54                     MethodInfo method = ((MethodCallExpression)lambda.Body).Method;
55                     Debug.Assert(!method.IsStatic && method.IsPublic &&
56                                  (method.DeclaringType == typeof(System.Data.Spatial.DbGeography) || method.DeclaringType == typeof(System.Data.Spatial.DbGeometry)),
57                                  "Supported instance spatial methods should be public instance methods declared by a spatial type");
58                     return method;
59                 }
60
61
62                 private static IEnumerable<MethodInfo> GetSupportedMethods()
63                 {
64                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromText(default(string)));
65                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromText(default(string), default(int)));
66                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.PointFromText(default(string), default(int)));
67                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.LineFromText(default(string), default(int)));
68                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.PolygonFromText(default(string), default(int)));
69                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPointFromText(default(string), default(int)));
70                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiLineFromText(default(string), default(int)));
71                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPolygonFromText(default(string), default(int)));
72                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.GeographyCollectionFromText(default(string), default(int)));
73                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromBinary(default(byte[]), default(int)));
74                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromBinary(default(byte[])));
75                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.PointFromBinary(default(byte[]), default(int)));
76                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.LineFromBinary(default(byte[]), default(int)));
77                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.PolygonFromBinary(default(byte[]), default(int)));
78                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPointFromBinary(default(byte[]), default(int)));
79                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiLineFromBinary(default(byte[]), default(int)));
80                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPolygonFromBinary(default(byte[]), default(int)));
81                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.GeographyCollectionFromBinary(default(byte[]), default(int)));
82                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromGml(default(string)));
83                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeography.FromGml(default(string), default(int)));
84                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsBinary());
85                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsGml());
86                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsText());
87                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.SpatialEquals(default(System.Data.Spatial.DbGeography)));
88                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Disjoint(default(System.Data.Spatial.DbGeography)));
89                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Intersects(default(System.Data.Spatial.DbGeography)));
90                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Buffer(default(double)));
91                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Distance(default(System.Data.Spatial.DbGeography)));
92                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Intersection(default(System.Data.Spatial.DbGeography)));
93                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Union(default(System.Data.Spatial.DbGeography)));
94                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Difference(default(System.Data.Spatial.DbGeography)));
95                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.SymmetricDifference(default(System.Data.Spatial.DbGeography)));
96                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.ElementAt(default(int)));
97                     yield return GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.PointAt(default(int)));
98                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromText(default(string)));
99                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromText(default(string), default(int)));
100                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.PointFromText(default(string), default(int)));
101                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.LineFromText(default(string), default(int)));
102                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.PolygonFromText(default(string), default(int)));
103                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPointFromText(default(string), default(int)));
104                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiLineFromText(default(string), default(int)));
105                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPolygonFromText(default(string), default(int)));
106                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.GeometryCollectionFromText(default(string), default(int)));
107                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromBinary(default(byte[])));
108                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromBinary(default(byte[]), default(int)));
109                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.PointFromBinary(default(byte[]), default(int)));
110                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.LineFromBinary(default(byte[]), default(int)));
111                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.PolygonFromBinary(default(byte[]), default(int)));
112                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPointFromBinary(default(byte[]), default(int)));
113                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiLineFromBinary(default(byte[]), default(int)));
114                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPolygonFromBinary(default(byte[]), default(int)));
115                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.GeometryCollectionFromBinary(default(byte[]), default(int)));
116                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromGml(default(string)));
117                     yield return GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromGml(default(string), default(int)));
118                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsBinary());
119                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsGml());
120                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsText());
121                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.SpatialEquals(default(System.Data.Spatial.DbGeometry)));
122                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Disjoint(default(System.Data.Spatial.DbGeometry)));
123                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Intersects(default(System.Data.Spatial.DbGeometry)));
124                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Touches(default(System.Data.Spatial.DbGeometry)));
125                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Crosses(default(System.Data.Spatial.DbGeometry)));
126                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Within(default(System.Data.Spatial.DbGeometry)));
127                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Contains(default(System.Data.Spatial.DbGeometry)));
128                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Overlaps(default(System.Data.Spatial.DbGeometry)));
129                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Relate(default(System.Data.Spatial.DbGeometry), default(string)));
130                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Buffer(default(double)));
131                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Distance(default(System.Data.Spatial.DbGeometry)));
132                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Intersection(default(System.Data.Spatial.DbGeometry)));
133                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Union(default(System.Data.Spatial.DbGeometry)));
134                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Difference(default(System.Data.Spatial.DbGeometry)));
135                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.SymmetricDifference(default(System.Data.Spatial.DbGeometry)));
136                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.ElementAt(default(int)));
137                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.PointAt(default(int)));
138                     yield return GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.InteriorRingAt(default(int)));
139                 }
140
141                 private static Dictionary<MethodInfo, string> GetRenamedMethodFunctions()
142                 {
143                     Dictionary<MethodInfo, string> result = new Dictionary<MethodInfo, string>();
144                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromText(default(string))), "GeographyFromText");
145                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromText(default(string), default(int))), "GeographyFromText");
146                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.PointFromText(default(string), default(int))), "GeographyPointFromText");
147                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.LineFromText(default(string), default(int))), "GeographyLineFromText");
148                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.PolygonFromText(default(string), default(int))), "GeographyPolygonFromText");
149                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPointFromText(default(string), default(int))), "GeographyMultiPointFromText");
150                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiLineFromText(default(string), default(int))), "GeographyMultiLineFromText");
151                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPolygonFromText(default(string), default(int))), "GeographyMultiPolygonFromText");
152                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.GeographyCollectionFromText(default(string), default(int))), "GeographyCollectionFromText");
153                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromBinary(default(byte[]), default(int))), "GeographyFromBinary");
154                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromBinary(default(byte[]))), "GeographyFromBinary");
155                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.PointFromBinary(default(byte[]), default(int))), "GeographyPointFromBinary");
156                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.LineFromBinary(default(byte[]), default(int))), "GeographyLineFromBinary");
157                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.PolygonFromBinary(default(byte[]), default(int))), "GeographyPolygonFromBinary");
158                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPointFromBinary(default(byte[]), default(int))), "GeographyMultiPointFromBinary");
159                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiLineFromBinary(default(byte[]), default(int))), "GeographyMultiLineFromBinary");
160                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.MultiPolygonFromBinary(default(byte[]), default(int))), "GeographyMultiPolygonFromBinary");
161                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.GeographyCollectionFromBinary(default(byte[]), default(int))), "GeographyCollectionFromBinary");
162                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromGml(default(string))), "GeographyFromGml");
163                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeography.FromGml(default(string), default(int))), "GeographyFromGml");
164                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsBinary()), "AsBinary");
165                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsGml()), "AsGml");
166                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.AsText()), "AsText");
167                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.SpatialEquals(default(System.Data.Spatial.DbGeography))), "SpatialEquals");
168                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Disjoint(default(System.Data.Spatial.DbGeography))), "SpatialDisjoint");
169                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Intersects(default(System.Data.Spatial.DbGeography))), "SpatialIntersects");
170                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Buffer(default(double))), "SpatialBuffer");
171                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Distance(default(System.Data.Spatial.DbGeography))), "Distance");
172                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Intersection(default(System.Data.Spatial.DbGeography))), "SpatialIntersection");
173                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Union(default(System.Data.Spatial.DbGeography))), "SpatialUnion");
174                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.Difference(default(System.Data.Spatial.DbGeography))), "SpatialDifference");
175                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.SymmetricDifference(default(System.Data.Spatial.DbGeography))), "SpatialSymmetricDifference");
176                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.ElementAt(default(int))), "SpatialElementAt");
177                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeography geo) => geo.PointAt(default(int))), "PointAt");
178                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromText(default(string))), "GeometryFromText");
179                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromText(default(string), default(int))), "GeometryFromText");
180                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.PointFromText(default(string), default(int))), "GeometryPointFromText");
181                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.LineFromText(default(string), default(int))), "GeometryLineFromText");
182                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.PolygonFromText(default(string), default(int))), "GeometryPolygonFromText");
183                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPointFromText(default(string), default(int))), "GeometryMultiPointFromText");
184                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiLineFromText(default(string), default(int))), "GeometryMultiLineFromText");
185                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPolygonFromText(default(string), default(int))), "GeometryMultiPolygonFromText");
186                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.GeometryCollectionFromText(default(string), default(int))), "GeometryCollectionFromText");
187                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromBinary(default(byte[]))), "GeometryFromBinary");
188                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromBinary(default(byte[]), default(int))), "GeometryFromBinary");
189                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.PointFromBinary(default(byte[]), default(int))), "GeometryPointFromBinary");
190                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.LineFromBinary(default(byte[]), default(int))), "GeometryLineFromBinary");
191                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.PolygonFromBinary(default(byte[]), default(int))), "GeometryPolygonFromBinary");
192                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPointFromBinary(default(byte[]), default(int))), "GeometryMultiPointFromBinary");
193                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiLineFromBinary(default(byte[]), default(int))), "GeometryMultiLineFromBinary");
194                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.MultiPolygonFromBinary(default(byte[]), default(int))), "GeometryMultiPolygonFromBinary");
195                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.GeometryCollectionFromBinary(default(byte[]), default(int))), "GeometryCollectionFromBinary");
196                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromGml(default(string))), "GeometryFromGml");
197                     result.Add(GetStaticMethod(() => System.Data.Spatial.DbGeometry.FromGml(default(string), default(int))), "GeometryFromGml");
198                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsBinary()), "AsBinary");
199                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsGml()), "AsGml");
200                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.AsText()), "AsText");
201                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.SpatialEquals(default(System.Data.Spatial.DbGeometry))), "SpatialEquals");
202                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Disjoint(default(System.Data.Spatial.DbGeometry))), "SpatialDisjoint");
203                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Intersects(default(System.Data.Spatial.DbGeometry))), "SpatialIntersects");
204                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Touches(default(System.Data.Spatial.DbGeometry))), "SpatialTouches");
205                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Crosses(default(System.Data.Spatial.DbGeometry))), "SpatialCrosses");
206                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Within(default(System.Data.Spatial.DbGeometry))), "SpatialWithin");
207                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Contains(default(System.Data.Spatial.DbGeometry))), "SpatialContains");
208                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Overlaps(default(System.Data.Spatial.DbGeometry))), "SpatialOverlaps");
209                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Relate(default(System.Data.Spatial.DbGeometry), default(string))), "SpatialRelate");
210                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Buffer(default(double))), "SpatialBuffer");
211                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Distance(default(System.Data.Spatial.DbGeometry))), "Distance");
212                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Intersection(default(System.Data.Spatial.DbGeometry))), "SpatialIntersection");
213                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Union(default(System.Data.Spatial.DbGeometry))), "SpatialUnion");
214                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.Difference(default(System.Data.Spatial.DbGeometry))), "SpatialDifference");
215                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.SymmetricDifference(default(System.Data.Spatial.DbGeometry))), "SpatialSymmetricDifference");
216                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.ElementAt(default(int))), "SpatialElementAt");
217                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.PointAt(default(int))), "PointAt");
218                     result.Add(GetInstanceMethod((System.Data.Spatial.DbGeometry geo) => geo.InteriorRingAt(default(int))), "InteriorRingAt");
219                     return result;
220                 }
221
222                 // Translator for spatial methods into canonical functions. Both static and instance methods are handled.
223                 // Unless a canonical function name is explicitly specified for a method, the mapping from method name to
224                 // canonical function name consists simply of applying the 'ST' prefix. Then, translation proceeds as follows:
225                 //      object.MethodName(args...)  -> CanonicalFunctionName(object, args...)
226                 //      Type.MethodName(args...)  -> CanonicalFunctionName(args...)
227                 internal override DbExpression Translate(ExpressionConverter parent, MethodCallExpression call)
228                 {
229                     MethodInfo method = (MethodInfo)call.Method;
230                     string canonicalFunctionName;
231                     if(!methodFunctionRenames.TryGetValue(method, out canonicalFunctionName))
232                     {
233                         canonicalFunctionName = "ST" + method.Name;
234                     }
235
236                     Expression[] arguments;
237                     if (method.IsStatic)
238                     {
239                         Debug.Assert(call.Object == null, "Static method call with instance argument?");
240                         arguments = call.Arguments.ToArray();
241                     }
242                     else
243                     {
244                         Debug.Assert(call.Object != null, "Instance method call with no instance argument?");
245                         arguments = new[] { call.Object }.Concat(call.Arguments).ToArray();
246                     }
247
248                     DbExpression result = parent.TranslateIntoCanonicalFunction(canonicalFunctionName, call, arguments);
249                     return result;
250                 }
251             }
252         }
253     }
254 }