Common Custom data source
Common_CustomDataSource_CSharp\TiledMapDataSource_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.
// 



using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using System.Collections;
using ESRI.ArcGIS.ADF.Web.DataSources;

namespace TiledMapDataSource_CSharp
{
    public class GISDataSource : IGISDataSource
    {

    public GISDataSource() { }

        public GISDataSource(string name, string dataSourceDefinition) : this(name, string.Empty, dataSourceDefinition) { }

        public GISDataSource(string name, string identity, string dataSourceDefinition)
        {
            this.name = name;
            this.identity = identity;
            this.dataSourceDefinition = dataSourceDefinition;
        }

 
        #region IGISDataSource implementation

        private Hashtable m_state;
        private string name = string.Empty;
        private string dataSourceDefinition = string.Empty;
        private string identity = string.Empty;
        private Page page = null;
        private GISResourceCollection resources = new GISResourceCollection();

        /// <summary>
        /// Name of the GIS Data Source
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }

        /// <summary>
        /// Definition of this data source
        /// </summary>
        public string DataSourceDefinition
        {
            get { return dataSourceDefinition; }
            set
            {
                if (dataSourceDefinition != value)
                {
                    dataSourceDefinition = value;
                }
            }
        }

        /// <summary>
        /// Identity of user connecting to data source
        /// </summary>
        public string Identity
        {
            get { return identity; }
            set { identity = value; }
        }

        /// <summary>
        /// The Page using this data source
        /// </summary>
        public Page Page
        {
            get { return page; }
            set { page = value; }
        }

        /// <summary>
        /// The collection of LodInfoNodes that this data source supports.
        /// </summary>
        public GISResourceCollection Resources
        {
            get { return resources; }
            set { resources = value; }
        }

        bool _initialized = false;
        /// <summary>
        /// Whether the data source has been initialized.
        /// </summary>
        public bool Initialized
        {
            get { return _initialized; }
        }

        /// <summary>
        /// Loads state
        /// </summary>
        /// <param name="state">Hashtable to store state in</param>
        public void LoadState(Hashtable state)
        {
            m_state = state;

        }

        /// <summary>
        /// Initializes the data source
        /// </summary>
        public void Initialize()
        {
            _initialized = true;
        }

        /// <summary>
        /// Saves state
        /// </summary>
    /// <returns>Hashtable with state</param>
        public Hashtable SaveState()
        {
            return m_state;
        }


        /// <summary>
        /// Disposes the data source
        /// </summary>
        public void Dispose() 
        {
            _initialized = false;
        }

        public Hashtable State
        {
            get
            {
                return m_state;
            }
        }

        /// <summary>
        /// Gets the definitions of available LodInfoNodes
        /// </summary>
        public string[] GetAvailableResourceDefinitions(System.Type resourceType)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        /// <summary>
        /// Creates a resource with the passed in definition
        /// </summary>
        /// <param name="resourceDefinition">The definition of the resource to be created.</param>
        /// <param name="name">The name of the resource to be created.</param>
        /// <returns>A GIS Resource with the passed in definition.</returns>
        public IGISResource CreateResource(string resourceDefinition, string name)
        {
            throw new Exception("The method or operation is not implemented.");
        }

        #endregion
    }
}