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

namespace GPPointFileInfo
{
    public class OutputHasZ : GPPointFileInfo.IOutputHasZ
    {
        private bool _hasZ;

        public OutputHasZ(IGPOutputGeometryDimensions gpOutputGeometryDimensions, IESOutputZFlag esOutputZFlag)
        {
            _hasZ = GetHasZ(gpOutputGeometryDimensions, esOutputZFlag);
        }

        public bool HasZ
        {
            get
            {
                return _hasZ;
            }
        }

        private bool GetHasZ(IGPOutputGeometryDimensions gpOutputGeometryDimensions, IESOutputZFlag esOutputZFlag)
        {
            bool hasZ;

            if (((gpOutputGeometryDimensions.GeometryDimensions == "2D") && (esOutputZFlag.Value == "Enabled")) || ((gpOutputGeometryDimensions.GeometryDimensions == "3D") && (esOutputZFlag.Value == "Disabled")))
            {
                throw new GPException(GPExceptionSeverity.Error, "Conflicting Input Settings." + ObjectToString.GetNewline() + "gpOutputGeometryDimensions.GeometryDimensions: " + ObjectToString.GetToString(gpOutputGeometryDimensions.GeometryDimensions) + "esOutputZFlag: " + ObjectToString.GetToString(esOutputZFlag));
            }
            else
            {
                hasZ = (gpOutputGeometryDimensions.GeometryDimensions == "3D");
            }

            return hasZ;
        }
    }
}