private void WriteFeatureLayer(FeatureLayer layer) { WriteAttribute("Url", layer.Url); if (!string.IsNullOrEmpty(layer.Where)) { WriteAttribute("Where", layer.Where); } if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(layer.ProxyUrl)) { WriteAttribute("ProxyUrl", layer.ProxyUrl); } if (!string.IsNullOrEmpty(layer.Token)) { WriteAttribute("Token", layer.Token); } } if (!string.IsNullOrEmpty(layer.Text)) { WriteAttribute("Text", layer.Text); } if (layer.MinimumResolution > double.Epsilon) { WriteAttribute("MinimumResolution", layer.MinimumResolution); } if (layer.MaximumResolution < double.MaxValue) { WriteAttribute("MaximumResolution", layer.MaximumResolution); } if (layer.Mode == FeatureLayer.QueryMode.OnDemand) { WriteAttribute("Mode", layer.Mode.ToString()); if (layer.OnDemandCacheSize != 1000) WriteAttribute("OnDemandCacheSize", layer.OnDemandCacheSize.ToString()); } if (layer.OutFields != null && layer.OutFields.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (string value in layer.OutFields) { sb.AppendFormat("{0},", value); } string str = sb.ToString(); if (str.Length > 0) { str = str.Remove(str.Length - 1); // remove trailing , writer.WriteAttributeString("OutFields", str); } } if (layer.Geometry != null) { //TODO } if (layer.ObjectIDs != null && layer.ObjectIDs.Length > 0) { string oidString = ""; foreach (int oid in layer.ObjectIDs) oidString += oid.ToString() + ","; oidString = oidString.Substring(0, oidString.Length - 1); writer.WriteAttributeString("ObjectIDs", oidString); } // Serialize feature collection JSON for feature collection layers if (string.IsNullOrEmpty(layer.Url) && layer.LayerInfo != null) { // feature collection layer. Retrieve and store feature collection JSON string json = layer.GenerateFeatureCollectionJson(); if (!string.IsNullOrEmpty(json)) { writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.FeatureCollectionJson", Constants.esriMappingNamespace, json); } } WriteBaseElementContents(layer); WriteGraphicsLayerElements(layer); }
private void WriteFeatureLayer(FeatureLayer layer) { WriteAttribute("Url", layer.Url); if (!string.IsNullOrEmpty(layer.Where)) { WriteAttribute("Where", layer.Where); } if (!LayerExtensions.GetUsesProxy(layer)) { if (!string.IsNullOrEmpty(layer.ProxyUrl)) { WriteAttribute("ProxyUrl", layer.ProxyUrl); } if (!string.IsNullOrEmpty(layer.Token)) { WriteAttribute("Token", layer.Token); } } if (!string.IsNullOrEmpty(layer.Text)) { WriteAttribute("Text", layer.Text); } if (layer.MinimumResolution > double.Epsilon) { WriteAttribute("MinimumResolution", layer.MinimumResolution); } if (layer.MaximumResolution < double.MaxValue) { WriteAttribute("MaximumResolution", layer.MaximumResolution); } if (layer.Mode == FeatureLayer.QueryMode.OnDemand) { WriteAttribute("Mode", layer.Mode.ToString()); if (layer.OnDemandCacheSize != 1000) { WriteAttribute("OnDemandCacheSize", layer.OnDemandCacheSize.ToString()); } } if (layer.OutFields != null && layer.OutFields.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (string value in layer.OutFields) { sb.AppendFormat("{0},", value); } string str = sb.ToString(); if (str.Length > 0) { str = str.Remove(str.Length - 1); // remove trailing , writer.WriteAttributeString("OutFields", str); } } if (layer.Geometry != null) { //TODO } if (layer.ObjectIDs != null && layer.ObjectIDs.Length > 0) { string oidString = ""; foreach (int oid in layer.ObjectIDs) { oidString += oid.ToString() + ","; } oidString = oidString.Substring(0, oidString.Length - 1); writer.WriteAttributeString("ObjectIDs", oidString); } // Serialize feature collection JSON for feature collection layers if (string.IsNullOrEmpty(layer.Url) && layer.LayerInfo != null) { // feature collection layer. Retrieve and store feature collection JSON string json = layer.GenerateFeatureCollectionJson(); if (!string.IsNullOrEmpty(json)) { writer.WriteElementString(Constants.esriMappingPrefix, "LayerExtensions.FeatureCollectionJson", Constants.esriMappingNamespace, json); } } WriteBaseElementContents(layer); WriteGraphicsLayerElements(layer); }