using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SOASystem.Data.FileGDBClient;
using Proxies;
namespace FileGDBProviderTest
{
class Domains
{
public static bool TestDomains()
{
FileGDBConnection conn = new FileGDBConnection(@"database=C:\FileGDBProvider\data\domains.gdb");
try
{
conn.Open();
try
{
Domain d = null;
try
{
conn.GetDomainDefinition("MedianType");
conn.DeleteDomain("MedianType");
}
catch { }
try
{
d = conn.GetDomainDefinition("SpeedLimit");
conn.DeleteDomain("SpeedLimit");
}
catch { }
}
catch (FileGDBException e2)
{

}

CodedValueDomain cvd = new CodedValueDomain();
cvd.FieldType = esriFieldType.esriFieldTypeSmallInteger;
cvd.DomainName = "SpeedLimit";
cvd.Description = "SpeedLimit decription domain";
CodedValue cv = new CodedValue();
cv.Name = "Test2";
cv.Code = 1;
List<CodedValue> cvs = new List<CodedValue>();
cvs.Add(cv);
cvd.CodedValues = cvs.ToArray();

// Create a domain
conn.CreateDomain(cvd);
Domain newD = conn.GetDomainDefinition("SpeedLimit");

// Alter coded value domain
cvd.MergePolicy= esriMergePolicyType.esriMPTSumValues;
conn.AlterDomain(cvd);

// Create a RangeDomain
//
RangeDomain rd = new RangeDomain();
rd.DomainName = "MedianType";
rd.FieldType = esriFieldType.esriFieldTypeSmallInteger;
rd.MinValue = 1;
rd.MaxValue = 10;

conn.CreateDomain(rd);

newD = conn.GetDomainDefinition("MedianType");

// Using AlterDomain
//
rd.MaxValue = 20;
conn.AlterDomain(rd);
}
catch (FileGDBException e)
{
FileGDBErrorCollection ec = e.Errors;
foreach (FileGDBError er in ec)
{
String msg = er.Message;
int hResult = er.ErrorCode;
}
}

return true;
}
}
}

Last edited Aug 25, 2011 at 6:15 PM by dotnetprovider, version 1

Comments

No comments yet.