예제 #1
0
        /// <summary>
        /// Initialse all objects, create new
        /// instances of all servers and cleanup
        /// objects when complete.
        /// </summary>
        /// <param name="create"></param>
        private void Initialise(bool create)
        {
            // Create new instances.
            if (create)
            {
                Configuration.ReaderHttp reader = new Configuration.ReaderHttp();

                _httpHtmlProviderHost         = new Server.HttpHtmlProvider();
                _httpHtmlProviderHost.UriList = reader.GetProviderPathPrefix(_httpHtmlProviderHost.ProviderName);

                _httpHtmlAuthProviderHost         = new Server.HttpHtmlAuthProvider();
                _httpHtmlAuthProviderHost.UriList = reader.GetProviderPathPrefix(_httpHtmlAuthProviderHost.ProviderName);

                _httpXmlFeedHost         = new Server.HttpXmlFeed();
                _httpXmlFeedHost.UriList = reader.GetProviderPathPrefix(_httpXmlFeedHost.ProviderName);

                _httpXmlAuthFeedHost         = new Server.HttpXmlAuthFeed();
                _httpXmlAuthFeedHost.UriList = reader.GetProviderPathPrefix(_httpXmlAuthFeedHost.ProviderName);

                _httpBasicProviderHost = new Server.HttpBasicProvider();
                _httpBasicProviderHost.UrlBaseAddress     = reader.GetProviderPathPrefix(_httpBasicProviderHost.ProviderName).First();
                _httpBasicProviderHost.LocalBaseDirectory = ReaderHttp.GetBaseDirectoryPath().TrimEnd('\\');
            }
            else
            {
                // Clean up each host.
                if (_httpHtmlProviderHost != null)
                {
                    _httpHtmlProviderHost = null;
                }

                // Clean up each host.
                if (_httpHtmlAuthProviderHost != null)
                {
                    _httpHtmlAuthProviderHost = null;
                }

                // Clean up each host.
                if (_httpXmlFeedHost != null)
                {
                    _httpXmlFeedHost = null;
                }

                // Clean up each host.
                if (_httpXmlAuthFeedHost != null)
                {
                    _httpXmlAuthFeedHost = null;
                }

                // Clean up each host.
                if (_httpBasicProviderHost != null)
                {
                    _httpBasicProviderHost = null;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// If disposing equals false, the method has been called by the
        /// runtime from inside the finalizer and you should not reference
        /// other objects. Only unmanaged resources can be disposed.
        /// </summary>
        protected virtual void Dispose(bool disposing)
        {
            // Check to see if Dispose has already been called.
            if (!this.disposed)
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if (disposing)
                {
                    // Dispose managed resources.
                    if (_httpHtmlProviderHost != null)
                    {
                        _httpHtmlProviderHost.Dispose();
                    }

                    if (_httpXmlFeedHost != null)
                    {
                        _httpXmlFeedHost.Dispose();
                    }

                    if (_httpHtmlAuthProviderHost != null)
                    {
                        _httpHtmlAuthProviderHost.Dispose();
                    }

                    if (_httpXmlAuthFeedHost != null)
                    {
                        _httpXmlAuthFeedHost.Dispose();
                    }

                    if (_httpBasicProviderHost != null)
                    {
                        _httpBasicProviderHost.Dispose();
                    }
                }

                // Call the appropriate methods to clean up
                // unmanaged resources here.
                _httpHtmlProviderHost     = null;
                _httpXmlFeedHost          = null;
                _httpHtmlAuthProviderHost = null;
                _httpXmlAuthFeedHost      = null;
                _httpBasicProviderHost    = null;

                _hostHtmlThread     = null;
                _hostHtmlAuthThread = null;
                _hostXmlThread      = null;
                _hostXmlAuthThread  = null;
                _hostBasicThread    = null;

                // Note disposing has been done.
                disposed = true;
            }
        }