Provides access to members that return information about domains and allows you to add or delete domains.
| Description | ||
|---|---|---|
![]() |
AddDomain | Adds the given domain to the workspace. |
![]() |
CanDeleteDomain | Indicates if the user can delete the domain. |
![]() |
DeleteDomain | Deletes the given domain from the workspace. |
![]() |
DomainByName | The domain with the given name from the workspace. |
![]() |
Domains | All the domains in the workspace. |
![]() |
DomainsByFieldType | The domain with the given name from the workspace. |
| CoClasses and Classes | Description |
|---|---|
| Sde4Workspace (esriDataSourcesGDB) | ESRI SDE (4.x) Feature Database. |
| VersionedWorkspace | VersionedWorkspace Object. |
| Workspace | Workspace Object. |
The IWorkspaceDomains interface is used for managing the collection of domains found within a workspace. Domains may be shared between fields in different object classes, thus they are managed (that is, created, deleted and modified) at the workspace level. It is important to keep in mind that a domain may not be deleted from a workspace if any field in an object class currently uses it. Domain names are also unique across a workspace; if you attempt to add a domain to a workspace and the specified name is already associated with an existing domain, an error will be returned.
Three of the four properties on the IWorkspaceDomain interface are used for returning to the user the domains that are currently associated with the workspace. The user can either request all of the domains (Domains), a particular domain by name (DomainByName), or all the domains that may be associated with a given field type (DomainsByFieldType).
//This function returns a requested domain by name from a supplied workspace.
//e.g., nameOfDomain = "Capacity constraint"
public IDomain IWorkspaceDomains__(IWorkspace workspace, string nameOfDomain)
{
IWorkspaceDomains workspaceDomains = workspace as IWorkspaceDomains;
return workspaceDomains.get_DomainByName(nameOfDomain);
//You may cast for the IWorkspaceDomains interface from the following object:
//IWorkspace
}
The following two examples are code excerpts that show how to get to an IWorkspaceDomains interface with Visual Basic for Applications and Visual Basic respecitvly.
When using VBA, you can use the table of contents in ArcMap to get at the feature class, then you can gets an interface to its workspace. You can then QI (query interface) for the IWorkspaceDomains interface.
Dim pFeatcls As IFeatureClass
Dim pFeatLayer As IFeatureLayer
Dim pDoc As IMxDocument
Dim pMap As IMap
Dim pWS as IWorkspace
Dim pWSDomains as IWorkspaceDomains
Set pDoc = ThisDocument
Set pMap = pDoc.Maps.Item(0)
Set pFeatLayer = pMap.Layer(0)
Set pFeatcls = pFeatLayer.FeatureClass
Set pWS = pFeatcls.FeatureDataset.Workspace
Set pWSDomains = pWS
With Visual Basic, you are working outside of the application, so you need to use code to get the workspace object, then QI for its IWorkspaceDomains interface. This example has the location of the connection file for the workspace hard-coded, but you could use the mini-browser to browse to the workspace.
Dim pFact As IWorkspaceFactory
Set pFact = New SdeWorkspaceFactory
Dim pWorkspace As IWorkspace
Set pWorkspace = pFact.OpenFromFile("C:\MyConnections\redarrow_gdb.sde",0)
Dim pWSDomains as IWorkspaceDomains
Set pWSDomains = pWorkspace
You can QI (Query Interface) for the IWorkspaceDomains interface from the following interfaces:
IWorkspace