Common_CustomDataSource_VBNet\REXMLDataSource_VBNet\GISDataSource.vb
' 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. ' Imports Microsoft.VisualBasic Imports System Namespace REXMLDataSource_VBNet ' IGISDataSource is the foundation of a Web ADF Common Data Source implementation. The class ' implementing this interface will be reponsible for creating resources, which in turn will be ' responsible for creating functionalities. IGISDataSource defines a data source connection, ' including the identity and state of that connection. So when any of the data source ' functionality defined in this assembly is needed - programmatically, by a Web ADF Control, or ' otherwise - instantiating this class is the first step in accessing the required functionality. ' ' Put more succinctly, an IGISDataSource implementation can be thought of as describing how the ' data can be accessed. Public Class GISDataSource Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource #Region "Instance Variables" Private m_stateHashTable As System.Collections.Hashtable Private m_name As String = String.Empty Private m_dataSourceDefinition As String = String.Empty Private m_identity As String = String.Empty Private m_page As System.Web.UI.Page = Nothing Private m_gisResourceCollection As ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection = New ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection() Private m_initialized As Boolean = False #End Region #Region "Constructors" ' Allow instantiation without defining any properties Public Sub New() End Sub ' Handle the instantiation case where identity is undefined via inheritance Public Sub New(ByVal name As String, ByVal dataSourceDefinition As String) Me.New(name, String.Empty, dataSourceDefinition) End Sub ' Explicitly set instance properties in cases where the class is instantiated with ' data source name, identity, and definition Public Sub New(ByVal name As String, ByVal identity As String, ByVal dataSourceDefinition As String) m_name = name m_identity = identity m_dataSourceDefinition = dataSourceDefinition End Sub #End Region #Region "IGISDataSource Members" #Region "IGISDataSource Properties" ' Name of the data source Public Property Name() As String Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Name Get Return m_name End Get Set(ByVal value As String) m_name = Value End Set End Property ' Definition of the data source. In this case, this will be the location of the ' REXML file. Public Property DataSourceDefinition() As String Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.DataSourceDefinition Get Return m_dataSourceDefinition End Get Set(ByVal value As String) If m_dataSourceDefinition <> Value Then m_dataSourceDefinition = Value End If End Set End Property ' Identity for connecting to the data source Public Property Identity() As String Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Identity Get Return m_identity End Get Set(ByVal value As String) m_identity = Value End Set End Property ' Page containing the web control referencing the data source Public Property Page() As System.Web.UI.Page Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Page Get Return m_page End Get Set(ByVal value As System.Web.UI.Page) m_page = Value End Set End Property ' Resources made available via this data source. These must implement IGISResource ' and provide access to the data source's functionality classes Public Property Resources() As ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Resources Get Return m_gisResourceCollection End Get Set(ByVal value As ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection) m_gisResourceCollection = Value End Set End Property ' Whether the data source has been initialized Public ReadOnly Property Initialized() As Boolean Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Initialized Get Return m_initialized End Get End Property ' Retrieves object state Public ReadOnly Property State() As System.Collections.Hashtable Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.State Get Return m_stateHashTable End Get End Property #End Region #Region "IGISDataSource Methods" ' Loads the passed-in state of the data source into the object. State retrieval ' from external sources would also be performed here, if needed. Public Sub LoadState(ByVal state As System.Collections.Hashtable) Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.LoadState m_stateHashTable = state End Sub ' Sets the initalized flag of the data source to true. Any needed initialization ' logic (e.g. initializing a connection) would be inserted here. Public Sub Initialize() Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Initialize m_initialized = True End Sub ' Saves the state of the data source. If something in the object's state needed ' to be persisted elsewhere, it would be done here. Public Function SaveState() As System.Collections.Hashtable Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.SaveState Return m_stateHashTable End Function ' Sets the initalized flag of the data source to false. Any logic needed to release ' or reset objects manipulated in Initialize would be inserted here. Public Sub Dispose() Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.Dispose m_initialized = False End Sub ' Function to find resource objects that use the data source and return their ' definition strings Public Function GetAvailableResourceDefinitions(ByVal resourceType As System.Type) As String() Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.GetAvailableResourceDefinitions Throw New System.Exception("The method or operation is not implemented.") End Function ' Function to create a resource based on the passed-in resource definition string and name Public Function CreateResource(ByVal resourceDefinition As String, ByVal name As String) As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource Implements ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource.CreateResource Throw New System.Exception("The method or operation is not implemented.") End Function #End Region #End Region End Class End Namespace