Skip to content

Commit 5ec1ef2

Browse files
Fixing obsolete old constructor for FeatureForm in samples (#696)
* Fixing obsolete old constructor for FeatureForm in samples * Addressing code review comments * restoring unnecessary commit
1 parent 14e7214 commit 5ec1ef2

File tree

3 files changed

+11
-29
lines changed

3 files changed

+11
-29
lines changed

src/Samples/Toolkit.SampleApp.Maui/Samples/FeatureFormViewSample.xaml.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ private async void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Maui.
2424
var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);
2525

2626
// Retrieves feature from IdentifyLayerResult with a form definition
27-
var feature = GetFeature(result, out var def);
27+
var feature = GetFeature(result);
2828
if (feature != null)
2929
{
30-
formViewer.FeatureForm = new FeatureForm(feature, def);
30+
formViewer.FeatureForm = new FeatureForm(feature);
3131
SidePanel.IsVisible = true;
3232
}
3333
}
@@ -37,19 +37,13 @@ private async void mapView_GeoViewTapped(object sender, Esri.ArcGISRuntime.Maui.
3737
}
3838
}
3939

40-
private ArcGISFeature? GetFeature(IEnumerable<IdentifyLayerResult> results, out FeatureFormDefinition? def)
40+
private ArcGISFeature? GetFeature(IEnumerable<IdentifyLayerResult> results)
4141
{
42-
def = null;
4342
if (results == null)
4443
return null;
4544
foreach (var result in results.Where(r => r.LayerContent is FeatureLayer layer && (layer.FeatureFormDefinition is not null || (layer.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition is not null)))
4645
{
47-
var feature = result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
48-
def = (result.LayerContent as FeatureLayer)?.FeatureFormDefinition ?? ((result.LayerContent as FeatureLayer)?.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition;
49-
if (feature != null && def != null)
50-
{
51-
return feature;
52-
}
46+
return result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
5347
}
5448

5549
return null;

src/Samples/Toolkit.SampleApp.UWP/Samples/Forms/FeatureFormViewSample.xaml.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
2727
var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);
2828

2929
// Retrieves feature from IdentifyLayerResult with a form definition
30-
var feature = GetFeature(result, out var def);
30+
var feature = GetFeature(result);
3131
if (feature != null)
3232
{
3333
formViewer.FeatureForm = new FeatureForm(feature);
@@ -40,19 +40,13 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
4040
}
4141
}
4242

43-
private ArcGISFeature GetFeature(IEnumerable<IdentifyLayerResult> results, out FeatureFormDefinition def)
43+
private ArcGISFeature GetFeature(IEnumerable<IdentifyLayerResult> results)
4444
{
45-
def = null;
4645
if (results == null)
4746
return null;
4847
foreach (var result in results.Where(r => r.LayerContent is FeatureLayer layer && (layer.FeatureFormDefinition is not null || (layer.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition is not null)))
4948
{
50-
var feature = result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
51-
def = (result.LayerContent as FeatureLayer)?.FeatureFormDefinition ?? ((result.LayerContent as FeatureLayer)?.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition;
52-
if (feature != null && def != null)
53-
{
54-
return feature;
55-
}
49+
return result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
5650
}
5751

5852
return null;

src/Samples/Toolkit.SampleApp.WPF/Samples/Forms/FeatureFormViewSample.xaml.cs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
2424
var result = await mapView.IdentifyLayersAsync(e.Position, 3, false);
2525

2626
// Retrieves feature from IdentifyLayerResult with a form definition
27-
var feature = GetFeature(result, out var def);
27+
var feature = GetFeature(result);
2828
if (feature != null)
2929
{
30-
formViewer.FeatureForm = new FeatureForm(feature, def);
30+
formViewer.FeatureForm = new FeatureForm(feature);
3131
SidePanel.Visibility = Visibility.Visible;
3232
}
3333
}
@@ -37,19 +37,13 @@ private async void mapView_GeoViewTapped(object sender, GeoViewInputEventArgs e)
3737
}
3838
}
3939

40-
private ArcGISFeature GetFeature(IEnumerable<IdentifyLayerResult> results, out FeatureFormDefinition def)
40+
private ArcGISFeature GetFeature(IEnumerable<IdentifyLayerResult> results)
4141
{
42-
def = null;
4342
if (results == null)
4443
return null;
4544
foreach (var result in results.Where(r => r.LayerContent is FeatureLayer layer && (layer.FeatureFormDefinition is not null || (layer.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition is not null)))
4645
{
47-
var feature = result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
48-
def = (result.LayerContent as FeatureLayer)?.FeatureFormDefinition ?? ((result.LayerContent as FeatureLayer)?.FeatureTable as ArcGISFeatureTable)?.FeatureFormDefinition;
49-
if (feature != null && def != null)
50-
{
51-
return feature;
52-
}
46+
return result.GeoElements?.OfType<ArcGISFeature>()?.FirstOrDefault();
5347
}
5448

5549
return null;

0 commit comments

Comments
 (0)