Import signposts
SignpostGPFunctionFactory.cs
// Copyright 2010 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 the use restrictions.
// 

using System;
using System.Runtime.InteropServices;

using ESRI.ArcGIS.ADF.CATIDs;           // for GPFunctionFactories.Register()

using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.Geoprocessing;

namespace GPImportSignpostFunctions
{
  /// <summary>
  /// Summary description for SignpostGPFunctionFactory.
  /// </summary>
  /// 
  [Guid("DD38447B-B17E-4e9e-913F-9B0437BB9B69")]
  [ClassInterface(ClassInterfaceType.None)]
  [ProgId("GPImportSignpostFunctions.SignpostGPFunctionFactory")]

  public class SignpostGPFunctionFactory : IGPFunctionFactory
  {

    #region COM Registration Function(s)
    [ComRegisterFunction()]
    [ComVisible(false)]
    private static void RegisterFunction(Type registerType)
    {
      string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
      GPFunctionFactories.Register(regKey);
    }

    [ComUnregisterFunction()]
    [ComVisible(false)]
    private static void UnregisterFunction(Type registerType)
    {
      string regKey = string.Format("HKEY_CLASSES_ROOT\\CLSID\\{{{0}}}", registerType.GUID);
      GPFunctionFactories.Unregister(regKey);
    }
    #endregion

    public SignpostGPFunctionFactory()
    {
    }

    #region IGPFunctionFactory Members

    public IGPFunction GetFunction(string name)
    {
      IGPFunction gpFunction = null;
      switch (name)
      {
        case "ImportDynamapSigns":
          gpFunction = new ImportDynamapSignsFunction() as IGPFunction;
          break;

        case "ImportNavStreetsSigns":
          gpFunction = new ImportNavStreetsSignsFunction() as IGPFunction;
          break;

        case "ImportMultiNetSigns":
          gpFunction = new ImportMultiNetSignsFunction() as IGPFunction;
          break;
      }
      return gpFunction;
    }

    public UID CLSID
    {
      get
      {
        UID pUID;
        pUID = new UIDClass();
        pUID.Value = "GPImportSignpostFunctions.SignpostGPFunctionFactory";
        return pUID;
      }
    }

    public IEnumGPName GetFunctionNames()
    {
      IArray array = new EnumGPNameClass();
      array.Add(GetFunctionName("ImportDynamapSigns"));
      array.Add(GetFunctionName("ImportNavStreetsSigns"));
      array.Add(GetFunctionName("ImportMultiNetSigns"));

      return array as IEnumGPName;
    }

    public string Name
    {
      get
      {
        return "Network Analyst Sample Tools";
      }
    }

    public IEnumGPEnvironment GetFunctionEnvironments()
    {
      return null;
    }

    public string Alias
    {
      get
      {
        return "Network Analyst Sample Tools";
      }
    }

    public IGPName GetFunctionName(string name)
    {
      IGPFunctionFactory functionFactory = new SignpostGPFunctionFactory();
      IGPFunctionName functionName = new GPFunctionNameClass();

      IGPName gpName;

      switch (name)
      {
        case "ImportDynamapSigns":
          gpName = functionName as IGPName;
          gpName.Name = name;
          gpName.Category = "Directions Data Setup";
          gpName.Description = "Create and populate Signpost Feature Class and Signpost Streets Table from Tele Atlas Dynamap data";
          gpName.DisplayName = "Import Dynamap Signs";
          gpName.Factory = functionFactory;
          return gpName;

        case "ImportNavStreetsSigns":
          gpName = functionName as IGPName;
          gpName.Name = name;
          gpName.Category = "Directions Data Setup";
          gpName.Description = "Create and populate Signpost Feature Class and Signpost Streets Table from NAVTEQ NAVSTREETS data";
          gpName.DisplayName = "Import NAVSTREETS Signs";
          gpName.Factory = functionFactory;
          return gpName;

        case "ImportMultiNetSigns":
          gpName = functionName as IGPName;
          gpName.Name = name;
          gpName.Category = "Directions Data Setup";
          gpName.Description = "Create and populate Signpost Feature Class and Signpost Streets Table from Tele Atlas MultiNet data";
          gpName.DisplayName = "Import MultiNet Signs";
          gpName.Factory = functionFactory;
          return gpName;
      }

      return null;
    }

    #endregion
  }
}