I'm trying to determine if specific layers are in the map before proceeding with more code. The following produces an error at the line where I am checking to the value == null of each layer.
Is this the best way to do this? Or is there a better way to check for specific layers in the map??
protected override void OnClick()
var gridLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Grid").FirstOrDefault() as BasicFeatureLayer;
var localMunicipalityLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_LocalMunicipality").FirstOrDefault() as BasicFeatureLayer;
var administrativeAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_AdministrativeArea").FirstOrDefault() as BasicFeatureLayer;
var communitiesLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_Communities").FirstOrDefault() as BasicFeatureLayer;
var depotAreaLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_DepotArea").FirstOrDefault() as BasicFeatureLayer;
var pressureZoneLayer = MapView.Active.Map.FindLayers("GISWRKS1.WORKS.LAND_PressureZone").FirstOrDefault() as BasicFeatureLayer;
****This is where I get the error!! If I check these one at a time, it works, but when combining with the || is when the error happens. In ArcMap 10.2, I have similar code running with no problems.****
if ((gridLayer == null) || (localMunicipalityLayer == null) || (administrativeAreaLayer == null) || (communitiesLayer == null) || (depotAreaLayer == null) || (pressureZoneLayer = null))
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Please add the LAND and Water Pressure Zone layers before proceeding.");
ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("All the layers are there!!");