This document is archived and information here might be outdated. Recommended version. |
Adds the given domain to the workspace.
[Visual Basic .NET] Public Function AddDomain ( _ ByVal Domain As IDomain _ ) As Integer
[C#] public int AddDomain ( IDomain Domain );
[C++]
HRESULT AddDomain(
IDomain* Domain
);
[C++] Parameters Domain [in]
Domain is a parameter of type IDomain*
The AddDomain method is used when adding a new domain to a workspace. An error will be returned if the domain name already exists on an existing domain within the workspace. AddDomain will return the identifier of the domain once it is added to the workspace.
An error will be raised if the domain name contains an invalid character when calling AddDomain. The list of invalid characters can be determined by using the ISQLSyntax::GetInvalidCharacters method, minus the slash (both / and \), hyphen (-), comma (,), and space characters.
If you are looking to assoicate an existing domain to a field (or subtype) see IClassSchemaEdit::AlterDomain (or ISubtypes::SetDomain).
public void AddDomain(IWorkspace workspace, string nameOfDomain)
{
//The function shows how to create a new range domain, then add it to the workspace.
IWorkspaceDomains workspaceDomains = workspace as IWorkspaceDomains;
//Create a new range domain
IRangeDomain rangeDomain = new RangeDomainClass();
rangeDomain.MaxValue = 2000;
rangeDomain.MinValue = 500;
IDomain domain = rangeDomain as IDomain;
domain.Name = nameOfDomain;
domain.FieldType = esriFieldType.esriFieldTypeDouble;
domain.SplitPolicy = esriSplitPolicyType.esriSPTGeometryRatio;
domain.MergePolicy = esriMergePolicyType.esriMPTSumValues;
//Add the new domain to the workspace;
workspaceDomains.AddDomain(domain);
}