Common_CustomDataSource_CSharp\REXMLDataSource_CSharp\GISDataSource.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. // namespace REXMLDataSource_CSharp { // 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 : ESRI.ArcGIS.ADF.Web.DataSources.IGISDataSource { #region Instance Variables private System.Collections.Hashtable m_stateHashTable; private string m_name = string.Empty; private string m_dataSourceDefinition = string.Empty; private string m_identity = string.Empty; private System.Web.UI.Page m_page = null; private ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection m_gisResourceCollection = new ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection(); private bool m_initialized = false; #endregion #region Constructors // Allow instantiation without defining any properties public GISDataSource() { } // Handle the instantiation case where identity is undefined via inheritance public GISDataSource(string name, string dataSourceDefinition) : this(name, string.Empty, dataSourceDefinition) { } // Explicitly set instance properties in cases where the class is instantiated with // data source name, identity, and definition public GISDataSource(string name, string identity, string dataSourceDefinition) { m_name = name; m_identity = identity; m_dataSourceDefinition = dataSourceDefinition; } #endregion #region IGISDataSource Members #region IGISDataSource Properties // Name of the data source public string Name { get { return m_name; } set { m_name = value; } } // Definition of the data source. In this case, this will be the location of the // REXML file. public string DataSourceDefinition { get { return m_dataSourceDefinition; } set { if (m_dataSourceDefinition != value) { m_dataSourceDefinition = value; } } } // Identity for connecting to the data source public string Identity { get { return m_identity; } set { m_identity = value; } } // Page containing the web control referencing the data source public System.Web.UI.Page Page { get { return m_page; } set { m_page = value; } } // Resources made available via this data source. These must implement IGISResource // and provide access to the data source's functionality classes public ESRI.ArcGIS.ADF.Web.DataSources.GISResourceCollection Resources { get { return m_gisResourceCollection; } set { m_gisResourceCollection = value; } } // Whether the data source has been initialized public bool Initialized { get { return m_initialized; } } // Retrieves object state public System.Collections.Hashtable State { get { return m_stateHashTable; } } #endregion #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 void LoadState(System.Collections.Hashtable state) { m_stateHashTable = state; } // Sets the initalized flag of the data source to true. Any needed initialization // logic (e.g. initializing a connection) would be inserted here. public void Initialize() { m_initialized = true; } // 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 System.Collections.Hashtable SaveState() { return m_stateHashTable; } // 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 void Dispose() { m_initialized = false; } // Function to find resource objects that use the data source and return their // definition strings public string[] GetAvailableResourceDefinitions(System.Type resourceType) { throw new System.Exception("The method or operation is not implemented."); } // Function to create a resource based on the passed-in resource definition string and name public ESRI.ArcGIS.ADF.Web.DataSources.IGISResource CreateResource(string resourceDefinition, string name) { throw new System.Exception("The method or operation is not implemented."); } #endregion #endregion } }