GPPointFileInfo\OutputFeatureCursor.vb
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\OutputFeatureCursor.vb
' Copyright 2008 ESRI
' 
' All rights reserved under the copyright laws of the United States
' and applicable international laws, treaties, and conventions.
' 
' You may freely redistribute and use this sample code, with or
' without modification, provided you include the original copyright
' notice and use restrictions.
' 
' See use restrictions at <your ArcGIS install location>/developerkit/userestrictions.txt.
' 

Imports Microsoft.VisualBasic
Imports System
Imports System.Runtime.InteropServices
Imports ESRI.ArcGIS.Geodatabase

Namespace GPPointFileInfo
  Public Class OutputFeatureCursor
        Implements GPPointFileInfo.IOutputFeatureCursor
    Private _featureCursor As IFeatureCursor

    Public Sub New(ByVal gpOutputFeatureClass As IGPOutputFeatureClass)
      _featureCursor = GetFeatureCursor(gpOutputFeatureClass)
    End Sub

    Private Function GetFeatureCursor(ByVal gpOutputFeatureClass As IGPOutputFeatureClass) As IFeatureCursor
      Const UseBuffering As Boolean = True

      Return gpOutputFeatureClass.FeatureClass.Insert(UseBuffering)
    End Function

        Public Sub InsertFeatureBuffer(ByVal outputFeatureBuffer As IOutputFeatureBuffer) Implements IOutputFeatureCursor.InsertFeatureBuffer
            Try
                _featureCursor.InsertFeature(outputFeatureBuffer.FeatureBuffer)
            Catch ex As COMException
                Throw New GPException(GPExceptionSeverity.Error, "Unable To Insert Output Feature Buffer Via Feature Cursor." & ObjectToString.GetNewline() & "_featureCursor: " & ObjectToString.GetToString(_featureCursor) & "outputFeatureBuffer: " & ObjectToString.GetToString(outputFeatureBuffer), ex)
            End Try
        End Sub

        Public Sub Flush() Implements IOutputFeatureCursor.Flush
            Try
                _featureCursor.Flush()
            Catch ex As COMException
                Throw New GPException(GPExceptionSeverity.Error, "Unable To Flush Feature Cursor. _featureCursor: " & ObjectToString.GetToString(_featureCursor), ex)
            End Try
        End Sub
  End Class
End Namespace