Wrapper class of a disposable IFeatureCursor which will automatically release the IFeatureCursor after the cursor is used.
Usage:
IFeatureCursor featureCursor = featureClass.Search(null, false);
using (DisposableFeatureCursor dispCursor = new DisposableFeatureCursor(featureCursor))
{
IEnumerable<IFeature> features = dispCursor.AsEnumerable();
foreach (IFeature f in features)
{
// perform your operation
}
}
//Get a new instance of the cursor featureCursor2. You can't reuse the existing featureCursor.
IFeatureCursor featureCursor2 = featureClass.Search(null, false);
using (DisposableFeatureCursor dispCursor2 = featureCursor2.ToDisposable())
{
IEnumerable<IFeature> features = dispCursor2.AsEnumerable();
int cnt = features.Count();
}
Constructors
Name | Description |
---|---|
DisposableFeatureCursor(IFeatureCursor) | Initializes a DisposableFeatureCursor. |
DisposableFeatureCursor(IFeatureCursor) Constructor
Creates a DisposableFeatureCursor from IFeatureCursor object. Note that a DisposableFeatureCursor cannot be wrapped or instantiated in another DisposableFeatureCursor instance, otherwise, an ArgumentException "Unable to wrap DisposableFeatureCursor in another DisposableFeatureCursor instance." will be thfeaturen by the constructor.
public DisposableFeatureCursor(IFeatureCursor cursor)
Parameter name | Type | Description |
---|---|---|
cursor | IFeatureCursor | The cursor to be made disposable. |
Property
Property | Property value | Description |
---|---|---|
DisposableFeatureCursor.Fields | IFields | The Fields Collection for this cursor. See IFeatureCursor.Fields |
Methods
Name | Description |
---|---|
DisposableFeatureCursor.Dispose | Release the cursor explicitly to avoid leaking database resources. |
DisposableFeatureCursor.DeleteFeature | Delete the existing Feature in the database corresponding to the current position of the cursor. |
DisposableFeatureCursor.FindField(String) | Find the index of the field with the specified name. |
DisposableFeatureCursor.Flush | Flush any outstanding buffered writes to the database. |
DisposableFeatureCursor.InsertFeature(IFeatureBuffer) | Insert a new Feature into the database using the property values in the input buffer. |
DisposableFeatureCursor.NextFeature | Advance the position of the cursor by one and return the Feature object at that position. |
DisposableFeatureCursor.UpdateFeature(IFeature) | Update the existing Feature in the database corresponding to the current position of the cursor. |
DisposableFeatureCursor.Dispose Method
Release the cursor to avoid leaking database resources.
public void Dispose()
DisposableFeatureCursor.DeleteFeature Method
Delete the existing Feature in the database corresponding to the current position of the cursor. See IFeatureCursor.DeleteFeature.
public void DeleteFeature()
DisposableFeatureCursor.FindField(String) Method
Find the index of the field with the specified name. See IFeatureCursor.FindField.
public int FindField(string name)
DisposableFeatureCursor.Flush Method
Flush any outstanding buffered writes to the database. See IFeatureCursor.Flush.
public void Flush()
DisposableFeatureCursor.InsertFeature(IFeatureBuffer) Method
Insert a new Feature into the database using the property values in the input buffer. The object ID of the new Feature, if there is one, is returned. See IFeatureCursor.InsertFeature.
public object InsertFeature(IFeatureBuffer buffer)
DisposableFeatureCursor.NextFeature Method
Advance the position of the cursor by one and return the Feature object at that position. See IFeatureCursor.NextFeature.
public IFeature NextFeature()
DisposableFeatureCursor.UpdateFeature(IFeature) Method
Update the existing Feature in the database corresponding to the current position of the cursor. See IFeatureCursor.UpdateFeature.
public void UpdateFeature(IFeature feature)