Public Property ServerConnection As CIMProjectServerConnection
public CIMProjectServerConnection ServerConnection {get; set;}
Public Property ServerConnection As CIMProjectServerConnection
public CIMProjectServerConnection ServerConnection {get; set;}
{
//This workflow would work for
var agsFilePath = @"C:\Data\ServerConnectionFiles\AcmeSampleService.ags";
//ServerConnectionProjectItem supports .ags, .wms, .wmts, .wfs, and .wcs files
var server_conn_item = ItemFactory.Instance.Create(agsFilePath)
as ArcGIS.Desktop.Catalog.ServerConnectionProjectItem;
//Get the server connection - passwords are never returned
var serverConnection = server_conn_item.ServerConnection as CIMProjectServerConnection;
//Add to an AGS service connection
var service_connection = new CIMAGSServiceConnection()
{
URL = "URL to the AGS _service_ on the AGS _server_",
ServerConnection = serverConnection
};
// Add a new layer to the map
var layerParams = new LayerCreationParams(service_connection);
layerParams.MapMemberPosition = MapMemberPosition.AddToBottom;
//Note: Needs QueuedTask to run
var layerCreated = LayerFactory.Instance.CreateLayer<FeatureLayer>(layerParams, map);
}
Target Platforms: Windows 11 Home, Pro, Enterprise (64 bit)