private static void setupShapefile(HttpContext context, Map m)
        {
            GeometryServices geometryServices = new GeometryServices();

            string[] layernames = new[]
                                      {
                                          "Countries",
                                          "Rivers"/*,
                                          "Cities"*/
                                      };

            foreach (string s in layernames)
            {
                ShapeFileProvider shapeFile =
               new ShapeFileProvider(context.Server.MapPath(string.Format("~/App_Data/Shapefiles/{0}.shp", s)),
                                     geometryServices.DefaultGeometryFactory,
                                     geometryServices.CoordinateSystemFactory, false);
                shapeFile.IsSpatiallyIndexed = false;

                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(shapeFile);

                GeoJsonGeometryStyle style = RandomStyle.RandomGeometryStyle();
                /* include GeoJson styles */
                style.IncludeAttributes = false;
                style.IncludeBBox = true;
                style.PreProcessGeometries = false;
                style.CoordinateNumberFormatString = "{0:F}";

                GeometryLayer geometryLayer = new GeometryLayer(s, style, provider);
                geometryLayer.Features.IsSpatiallyIndexed = false;
                m.AddLayer(geometryLayer);
                provider.Open();
            }

        }
        private static void setupShapefile(HttpContext context, Map m)
        {
            GeometryServices geometryServices = new GeometryServices();

            string[] layernames = new[]
            {
                "Countries",
                "Rivers"                          /*,
                                                   * "Cities"*/
            };

            foreach (string s in layernames)
            {
                ShapeFileProvider shapeFile =
                    new ShapeFileProvider(context.Server.MapPath(string.Format("~/App_Data/Shapefiles/{0}.shp", s)),
                                          geometryServices.DefaultGeometryFactory,
                                          geometryServices.CoordinateSystemFactory, false);
                shapeFile.IsSpatiallyIndexed = false;

                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(shapeFile);

                GeoJsonGeometryStyle style = RandomStyle.RandomGeometryStyle();
                /* include GeoJson styles */
                style.IncludeAttributes            = false;
                style.IncludeBBox                  = true;
                style.PreProcessGeometries         = false;
                style.CoordinateNumberFormatString = "{0:F}";

                GeometryLayer geometryLayer = new GeometryLayer(s, style, provider);
                geometryLayer.Features.IsSpatiallyIndexed = false;
                m.AddLayer(geometryLayer);
                provider.Open();
            }
        }
        private static void setupMsSqlSpatial(Map m)
        {
            string[] layernames = new[]
                                      {"Rivers",
                                          "Countries"
                                          /*,
                                          "Cities"*/
                                      };

            string sridstr = SridMap.DefaultInstance.Process(4326, "");

            foreach (string lyrname in layernames)
            {
                string tbl = lyrname;


                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(
                    new MsSqlSpatialProvider(
                        new GeometryServices()[sridstr],
                        ConfigurationManager.ConnectionStrings["db"].ConnectionString,
                        "st",
                        "dbo",
                        tbl,
                        "oid",
                        "Geometry")
                        {
                            DefaultProviderProperties
                                = new ProviderPropertiesExpression(
                                new ProviderPropertyExpression[]
                                    {
                                        new WithNoLockExpression(true)
                                    })
                        });


                GeoJsonGeometryStyle style = new GeoJsonGeometryStyle();

                switch (tbl)
                {
                    case "Rivers":
                        {
                            StyleBrush brush = new SolidStyleBrush(StyleColor.Blue);
                            StylePen pen = new StylePen(brush, 1);
                            style.Enabled = true;
                            style.EnableOutline = true;
                            style.Line = pen;
                            style.Fill = brush;
                            break;
                        }

                    case "Countries":
                        {
                            StyleBrush brush = new SolidStyleBrush(new StyleColor(0, 0, 0, 255));
                            StylePen pen = new StylePen(brush, 2);
                            style.Enabled = true;
                            style.EnableOutline = true;
                            style.Line = pen;
                            style.Fill = new SolidStyleBrush(StyleColor.Green);

                            break;
                        }

                    default:
                        {
                            style = RandomStyle.RandomGeometryStyle();
                            style.MaxVisible = 100000;
                            break;
                        }
                }


                /* include GeoJson styles */
                style.IncludeAttributes = false;
                style.IncludeBBox = true;
                style.PreProcessGeometries = false;
                style.CoordinateNumberFormatString = "{0:F}";
                GeometryLayer layer = new GeometryLayer(tbl, style, provider);
                layer.Features.IsSpatiallyIndexed = false;
                layer.AddProperty(AppStateMonitoringFeatureLayerProperties.AppStateMonitor, provider.Monitor);
                m.AddLayer(layer);
            }
        }
        private static void setupMsSqlSpatial(Map m)
        {
            string[] layernames = new[]
            { "Rivers",
              "Countries"

              /*,
               * "Cities"*/
            };

            string sridstr = SridMap.DefaultInstance.Process(4326, "");

            foreach (string lyrname in layernames)
            {
                string tbl = lyrname;


                AppStateMonitoringFeatureProvider provider = new AppStateMonitoringFeatureProvider(
                    new MsSqlSpatialProvider(
                        new GeometryServices()[sridstr],
                        ConfigurationManager.ConnectionStrings["db"].ConnectionString,
                        "st",
                        "dbo",
                        tbl,
                        "oid",
                        "Geometry")
                {
                    DefaultProviderProperties
                        = new ProviderPropertiesExpression(
                              new ProviderPropertyExpression[]
                    {
                        new WithNoLockExpression(true)
                    })
                });


                GeoJsonGeometryStyle style = new GeoJsonGeometryStyle();

                switch (tbl)
                {
                case "Rivers":
                {
                    StyleBrush brush = new SolidStyleBrush(StyleColor.Blue);
                    StylePen   pen   = new StylePen(brush, 1);
                    style.Enabled       = true;
                    style.EnableOutline = true;
                    style.Line          = pen;
                    style.Fill          = brush;
                    break;
                }

                case "Countries":
                {
                    StyleBrush brush = new SolidStyleBrush(new StyleColor(0, 0, 0, 255));
                    StylePen   pen   = new StylePen(brush, 2);
                    style.Enabled       = true;
                    style.EnableOutline = true;
                    style.Line          = pen;
                    style.Fill          = new SolidStyleBrush(StyleColor.Green);

                    break;
                }

                default:
                {
                    style            = RandomStyle.RandomGeometryStyle();
                    style.MaxVisible = 100000;
                    break;
                }
                }


                /* include GeoJson styles */
                style.IncludeAttributes            = false;
                style.IncludeBBox                  = true;
                style.PreProcessGeometries         = false;
                style.CoordinateNumberFormatString = "{0:F}";
                GeometryLayer layer = new GeometryLayer(tbl, style, provider);
                layer.Features.IsSpatiallyIndexed = false;
                layer.AddProperty(AppStateMonitoringFeatureLayerProperties.AppStateMonitor, provider.Monitor);
                m.AddLayer(layer);
            }
        }