GPPointFileInfo\ESExtent.cs
Creating a non-trival custom GP tool - inputs, outputs, and responding to environment settings
GPPointFileInfo\ESExtent.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 ESRI.ArcGIS.Geoprocessing;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geometry;

namespace GPPointFileInfo
{
    public class ESExtent : GPPointFileInfo.IESExtent
    {
        private const string _EnvironmentName = "extent";
        private IEnvelope _envelope;

        public ESExtent(IGPEnvironmentManager gpEnvironmentManager)
        {
            IGPValue gpValue = gpEnvironmentManager.GetGPValue(_EnvironmentName);

            _envelope = GetEnvelope(gpValue);
        }

        public IEnvelope Envelope
        {
            get
            {
                return _envelope;
            }
        }

        private IEnvelope GetEnvelope(IGPValue gpValue)
        {
            IEnvelope envelope;

            IGPExtent gpExtent = gpValue as IGPExtent;

            esriGPExtentEnum extentType;

            envelope = gpExtent.GetExtent(out extentType);

            return envelope;
        }
    }
}