// Potential cleanup; this could be a derived property from the other layer properties private static string GetDataSourceFullNameFromLayer(ILayer layer) { if (!(layer is IDataLayer)) { return(null); } string workspace = LayerUtilities.GetWorkspacePathFromLayer(layer); string container = LayerUtilities.GetDataSourceContainerFromLayer(layer); string dataset = LayerUtilities.GetDataSourceNameFromLayer(layer); if (dataset == null) { return(null); } if (workspace == null) { return(dataset); } if (container == null) { return(Path.Combine(workspace, dataset)); } return(Path.Combine(Path.Combine(workspace, container), dataset)); }
private void Initialize(ILayer layer) { // Layer properties Name = layer.Name; DataType = LayerUtilities.GetLayerDescriptionFromLayer(layer); IsGroup = DataType == "Group Layer"; SubLayers = GetSubLayers(layer); // data source properties; if (LayerUtilities.HasDataSetName(layer)) { DataSource = GetDataSourceFullNameFromLayer(layer); WorkspacePath = LayerUtilities.GetWorkspacePathFromLayer(layer); WorkspaceProgId = LayerUtilities.GetWorkspaceProgIDFromLayer(layer); WorkspaceType = LayerUtilities.GetWorkspaceTypeFromLayer(layer); Container = LayerUtilities.GetDataSourceContainerFromLayer(layer); ContainerType = LayerUtilities.GetDataSourceContainerTypeFromLayer(layer); DataSourceName = LayerUtilities.GetDataSourceNameFromLayer(layer); DataSetName = LayerUtilities.GetDataSetNameFromLayer(layer); DataSetType = LayerUtilities.GetDataSetTypeFromLayer(layer); } else if (LayerUtilities.HasAGSServerObjectName(layer)) { DataSource = LayerUtilities.GetURLFromAGSLayer(layer); DataSourceName = LayerUtilities.GetNameFromAGSLayer(layer); DataSetName = DataSourceName; DataSetType = LayerUtilities.GetTypeFromAGSLayer(layer); WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; } else if (LayerUtilities.HasIMSServiceDescription(layer)) { DataSource = LayerUtilities.GetURLFromIMSLayer(layer); DataSourceName = LayerUtilities.GetNameFromIMSLayer(layer); DataSetName = DataSourceName; DataSetType = LayerUtilities.GetTypeFromIMSLayer(layer); WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; } else if (LayerUtilities.HasWMSConnectionName(layer)) { DataSource = LayerUtilities.GetURLFromWMSLayer(layer); DataSourceName = DataSource; DataSetName = DataSource; DataSetType = LayerUtilities.GetAllPropertiesFromWMSLayer(layer); WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; } else if (LayerUtilities.HasWMTSConnectionName(layer)) { DataSource = LayerUtilities.GetURLFromWMTSLayer(layer); DataSourceName = DataSource; DataSetName = DataSource; DataSetType = LayerUtilities.GetAllPropertiesFromWMSLayer(layer); WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; } else if (LayerUtilities.HasDataSourceName(layer)) { DataSource = LayerUtilities.GetDataSourceName(layer); DataSourceName = DataSource; DataSetName = DataSource; DataSetType = DataSource; WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; } else { DataSource = "!Error, Unable to determine data source type"; WorkspacePath = null; WorkspaceProgId = null; WorkspaceType = null; Container = null; ContainerType = null; DataSourceName = null; DataSetName = null; DataSetType = null; } if (string.IsNullOrEmpty(DataSource)) { DataSource = "!Error - Data source not found"; } }