ArcGIS Pro 3.0 API Reference Guide
ArcGIS.Core.Data.DDL Namespace / CodedValueDomainToken Class
Members Example

In This Topic
    CodedValueDomainToken Class
    In This Topic
    The Token object to handle schema operations with a ArcGIS.Core.Data.CodedValueDomain.
    Syntax
    public sealed class CodedValueDomainToken : Token 
    Public NotInheritable Class CodedValueDomainToken 
       Inherits Token
    Example
    Creating a CodedValue domain
    // Create a CodedValueDomain description for water pipes
    CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription("WaterPipeTypes", FieldType.String,
      new SortedList<object, string> { { "Copper", "C_1" },
        { "Steel", "S_2" } })
    {
      SplitPolicy = SplitPolicy.Duplicate,
      MergePolicy = MergePolicy.DefaultValue
    };
    
    SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
    // Create a coded value domain 
    CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(codedValueDomainDescription);
    schemaBuilder.Build();
    
    Adding a Field that uses a domain
    // Adding a field,'PipeType', which uses the coded value domain to the 'Pipes' FeatureClass
    
    //The FeatureClass to add field
    string featureClassName = "Pipes";
    
    SchemaBuilder schemaBuilder = new SchemaBuilder(geodatabase);
    
    // Create a CodedValueDomain description for water pipes
    CodedValueDomainDescription pipeDomainDescription = 
      new CodedValueDomainDescription("WaterPipeTypes", FieldType.String,
      new SortedList<object, string> { { "Copper", "C_1" },
        { "Steel", "S_2" } })
    {
      SplitPolicy = SplitPolicy.Duplicate,
      MergePolicy = MergePolicy.DefaultValue
    };
    
    // Create a coded value domain token
    CodedValueDomainToken codedValueDomainToken = schemaBuilder.Create(pipeDomainDescription);
    
    // Create a new description from domain token
    CodedValueDomainDescription codedValueDomainDescription = new CodedValueDomainDescription(codedValueDomainToken);
    
    // Create a field named as 'PipeType' using a domain description
    FieldDescription domainFieldDescription = new FieldDescription("PipeType", FieldType.String)
    { DomainDescription = codedValueDomainDescription };
    
    //Retrieve existing information for 'Pipes' FeatureClass
    FeatureClassDefinition originalFeatureClassDefinition = geodatabase.GetDefinition<FeatureClassDefinition>(featureClassName);
    FeatureClassDescription originalFeatureClassDescription = 
      new FeatureClassDescription(originalFeatureClassDefinition);
    
    // Add domain field on existing fields
    List<FieldDescription> modifiedFieldDescriptions = new List<FieldDescription>(originalFeatureClassDescription.FieldDescriptions) { domainFieldDescription };
    
    // Create a new description with updated fields for 'Pipes' FeatureClass 
    FeatureClassDescription featureClassDescription = 
      new FeatureClassDescription(originalFeatureClassDescription.Name, modifiedFieldDescriptions,
                                     originalFeatureClassDescription.ShapeDescription);
    
    // Update the 'Pipes' FeatureClass with domain field
    schemaBuilder.Modify(featureClassDescription);
    
    // Build status
    bool buildStatus = schemaBuilder.Build();
    
    // Build errors
    if (!buildStatus)
    {
      IReadOnlyList<string> errors = schemaBuilder.ErrorMessages;
    }
    
    
    Inheritance Hierarchy

    System.Object
       ArcGIS.Core.Data.DDL.Token
          ArcGIS.Core.Data.DDL.CodedValueDomainToken

    Requirements

    Target Platforms: Windows 11, Windows 10, Windows 8.1

    See Also