|
/*
*
* iFinity Smart Business Solutions - http://www.ifinity.com.au
* Copyright (c) 2006
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), the rights to use, copy, modify, merge, publish, distribute, sublicense
* copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
* following conditions:
* 1. The above copyright notice and this permission notice shall be included in all copies or substantial portions
* of the Software.
* 2. The software may not be claimed as the original work of anyone other than the author and may not be sold as
* a stand alone product
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
using System;
using System.Collections.Generic;
using System.Text;
using System.Web.Configuration;
using System.Configuration.Provider;
namespace iFinity.Providers.GoogleSiteMap
{
public class GoogleSiteMapService
{
private static GoogleSiteMapProvider _provider = null;
private static GoogleSiteMapProviderCollection _providers = null;
private static object _lock = new object();
public static string GetGoogleSiteMap(string siteURL)
{
//ensure providers are loaded
LoadSiteMapProviders();
//delegate to the default provider
return _provider.GetGoogleSiteMap(siteURL);
}
private static void LoadSiteMapProviders()
{
if (_provider == null)
{
lock (_lock)
{
//double check provider still null
if (_provider == null)
{
//get reference to GoogleSiteMaps section
GoogleSiteMapSection section = (GoogleSiteMapSection)WebConfigurationManager.GetSection("googlesitemaps");
//load the registered providers and point _provider to default provider
_providers = new GoogleSiteMapProviderCollection();
ProvidersHelper.InstantiateProviders(section.Providers, _providers, typeof(GoogleSiteMapProvider));
_provider = _providers[section.DefaultProvider];
if (_provider == null)
{
throw new ProviderException("Unable to load default GoogleSiteMapProvider");
}
}
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.