ArcObjects Library Reference  

SignpostGPFunctionFactory

About the Import signposts Sample

[C#]

SignpostGPFunctionFactory.cs

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
	}
}

[Visual Basic .NET]

SignpostGPFunctionFactory.vb

Imports System
Imports System.Runtime.InteropServices

Imports ESRI.ArcGIS.ADF.CATIDs			 ' for GPFunctionFactories.Register()

Imports ESRI.ArcGIS.esriSystem
Imports ESRI.ArcGIS.Geodatabase
Imports ESRI.ArcGIS.Geoprocessing

Namespace GPImportSignpostFunctions
	<Guid("6CB22E71-856E-459a-89FA-34CDE2A3DCC4")> _
	<ClassInterface(ClassInterfaceType.None)> _
	<ProgId("GPImportSignpostFunctions.SignpostGPFunctionFactory")> _
	Public Class SignpostGPFunctionFactory
		Implements IGPFunctionFactory

#Region "COM Registration Function(s)"
		<ComRegisterFunction()> _
		<ComVisible(False)> _
		Private Shared Sub RegisterFunction(ByVal registerType As Type)
			Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
			GPFunctionFactories.Register(regKey)
		End Sub

		<ComUnregisterFunction()> _
		<ComVisible(False)> _
		Private Shared Sub UnregisterFunction(ByVal registerType As Type)
			Dim regKey As String = String.Format("HKEY_CLASSES_ROOT\CLSID\{{{0}}}", registerType.GUID)
			GPFunctionFactories.Unregister(regKey)
		End Sub
#End Region

		Public Sub New()
		End Sub

#Region "IGPFunctionFactory Members"

		Public Function GetFunction(ByVal name As String) As IGPFunction Implements IGPFunctionFactory.GetFunction
			Dim gpFunction As IGPFunction = Nothing
			Select Case name
				Case "ImportDynamapSigns"
					gpFunction = New ImportDynamapSignsFunction()
				Case "ImportNavStreetsSigns"
					gpFunction = New ImportNavStreetsSignsFunction()
				Case "ImportMultiNetSigns"
					gpFunction = New ImportMultiNetSignsFunction()
			End Select
			Return gpFunction
		End Function

		Public ReadOnly Property CLSID() As UID Implements IGPFunctionFactory.CLSID
			Get
				Dim pUID As UID
				pUID = New UID
				pUID.Value = "GPImportSignpostFunctions.SignpostGPFunctionFactory"
				Return pUID
			End Get
		End Property

		Public Function GetFunctionNames() As IEnumGPName Implements IGPFunctionFactory.GetFunctionNames
			Dim array As IArray = New EnumGPName
			array.Add(GetFunctionName("ImportDynamapSigns"))
			array.Add(GetFunctionName("ImportNavStreetsSigns"))
			array.Add(GetFunctionName("ImportMultiNetSigns"))

			Return CType(array, IEnumGPName)
		End Function

		Public ReadOnly Property Name() As String Implements IGPFunctionFactory.Name
			Get
				Return "Network Analyst Sample Tools"
			End Get
		End Property

		Public Function GetFunctionEnvironments() As IEnumGPEnvironment Implements IGPFunctionFactory.GetFunctionEnvironments
			Return Nothing
		End Function

		Public ReadOnly Property SignpostFactoryAlias() As String Implements IGPFunctionFactory.Alias
			Get
				Return "Network Analyst Sample Tools"
			End Get
		End Property

		Public Function GetFunctionName(ByVal Name As String) As IGPName Implements IGPFunctionFactory.GetFunctionName
			Dim functionFactory As IGPFunctionFactory = New SignpostGPFunctionFactory()
			Dim functionName As IGPFunctionName = New GPFunctionName

			Dim gpName As IGPName

			Select Case Name
				Case "ImportDynamapSigns"
					gpName = CType(functionName, 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 = CType(functionName, 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 = CType(functionName, 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
			End Select

			Return Nothing
		End Function

#End Region
	End Class
End Namespace