ArcGIS Pro 3.6 API Reference Guide
ArcGIS.Desktop.Mapping Namespace / LayerCreationRollbackBehavior Enumeration
Example Example

In This Topic
    LayerCreationRollbackBehavior Enumeration
    In This Topic
    Details the set of rollback behaviors for the LayerFactory.CreateLayers method when the BulkLayerCreationParams object is created with a set of LayerCreationParams objects.

    CreateLayers will create the layers it is able to per the data supplied. If invalid data sources are supplied, there will be a mismatch in the number of layers created (and returned from the function) compared to the number of data items supplied. When a set of LayerCreationParams objects exist, the bulk layer creation process applies the appropriate individual layer properties to the created layers, skipping the layer properties for any data sources that are in error. However there may be situations where this logic cannot be correctly applied and so the layers are still created but without the individual properties applied.

    Use the BulkLayerCreationParams.RollbackBehavior to control the behavior of bulk layer creation in these scenarios.

    Syntax
    Members
    MemberDescription
    NoRollbackNo rollback of the layer creation process occurs.

    The CreateLayers method will create the layers it is able to per the data supplied. Individual layer properties are applied if possible. If not, then the layers created do not have these properties applied.

    RollbackOnCannotApplyLayerProperties The layer creation process is rolled back if there is a mismatch in the number of layers created compared to the number of data sources supplied AND the correct individual layer properties cannot be applied.
    RollbackOnMissingLayers The layer creation process is rolled back if there is a mismatch in the number of layers created compared to the number of data sources supplied.
    Example
    Create multiple layers with BulkLayerCreationParams - Using RollbackBehavior
    var uriShp = new Uri(@"c:\data\roads.shp");
    var uriSde = new Uri(@"c:\MyDataConnections\MySDE.sde\Census");
    var uri = new Uri(@"http://sampleserver6.arcgisonline.com/arcgis/rest/services/NapervilleShelters/FeatureServer/0");
    
    var lcpShp = new FeatureLayerCreationParams(uriShp);
    lcpShp.Name = "Roads";
    lcpShp.IsVisible = false;
    lcpShp.DefinitionQuery = new DefinitionQuery("shpQuery", "OBJECTID > 10");
    
    var lcpSde = new FeatureLayerCreationParams(uriSde);
    lcpSde.Name = "Census Polygons";
    lcpSde.IsVisible = true;
    
    var lcpService = new FeatureLayerCreationParams(uri);
    lcpService.Name = "Shelters";
    lcpService.IsVisible = true;
    // set some renderer here ...
    //lcpService.RendererDefinition = ...
    
    var lcps = new List<FeatureLayerCreationParams>();
    lcps.Add(lcpShp);
    lcps.Add(lcpSde);
    lcps.Add(lcpService);
    
    var blkParams = new BulkLayerCreationParams(lcps);
    // set the positioning on the BulkLayerCreationParams
    blkParams.MapMemberPosition = MapMemberPosition.Index;
    blkParams.MapMemberIndex = 0;
    
    // set the rollback behavior
    // - rollback if one or more layers cannot be created due to an invalid data source
    blkParams.RollbackBehavior = LayerCreationRollbackBehavior.RollbackOnMissingLayers;
    
    var layers = LayerFactory.Instance.CreateLayers(blkParams, MapView.Active.Map);
    Inheritance Hierarchy

    System.Object
       System.ValueType
          System.Enum
             ArcGIS.Desktop.Mapping.LayerCreationRollbackBehavior

    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3.6 or higher.
    See Also