GPPointFileInfo\OutputFeatureCursor.cs
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\OutputFeatureCursor.cs
// 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.
// 

using System;
using System.Runtime.InteropServices;
using ESRI.ArcGIS.Geodatabase;

namespace GPPointFileInfo
{
    public class OutputFeatureCursor : GPPointFileInfo.IOutputFeatureCursor
    {
        private IFeatureCursor _featureCursor;

        public OutputFeatureCursor(IGPOutputFeatureClass gpOutputFeatureClass)
        {
            _featureCursor = GetFeatureCursor(gpOutputFeatureClass);
        }

        private IFeatureCursor GetFeatureCursor(IGPOutputFeatureClass gpOutputFeatureClass)
        {
            const bool UseBuffering = true;

            return gpOutputFeatureClass.FeatureClass.Insert(UseBuffering);
        }

        public void InsertFeatureBuffer(IOutputFeatureBuffer outputFeatureBuffer)
        {
            try
            {
                _featureCursor.InsertFeature(outputFeatureBuffer.FeatureBuffer);
            }
            catch (COMException ex)
            {
                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);
            }
        }

        public void Flush()
        {
            try
            {
                _featureCursor.Flush();
            }
            catch (COMException ex)
            {
                throw new GPException(GPExceptionSeverity.Error, "Unable To Flush Feature Cursor. _featureCursor: " + ObjectToString.GetToString(_featureCursor), ex);
            }
        }
    }
}