using System;
using System.Configuration;
using System.Collections.Generic;
namespace Yavsc
{
///
/// Thanks helper.
///
public static class ThanksHelper {
static private ThanksConfigurationSection configurationSection=null;
///
/// Gets the configuration section.
///
/// The configuration section.
static public ThanksConfigurationSection ConfigurationSection {
get {
if (configurationSection==null)
configurationSection = (ThanksConfigurationSection) ConfigurationManager.GetSection ("system.web/thanks");
return configurationSection;
}
}
///
/// Html code for each entry
///
public static string[] Links ()
{
List result = new List() ;
if (ConfigurationSection == null) return result.ToArray();
if (ConfigurationSection.To == null) return result.ToArray();
foreach (ThanksConfigurationElement e in ConfigurationSection.To) {
string link = "";
if (!string.IsNullOrEmpty(e.Url))
link = string.Format("",e.Url);
string dsp = (string.IsNullOrEmpty(e.Display))?e.Name:e.Display;
if (!string.IsNullOrEmpty(e.Image)) {
string ttl = (string.IsNullOrEmpty(ConfigurationSection.TitleFormat))?"Go and see the website ({0})":ConfigurationSection.TitleFormat;
ttl = string.Format(ttl,dsp);
link += string.Format(
"",
dsp,e.Image,ttl);
}
else link += dsp;
if (e.Url!=null)
link += " ";
result.Add (link);
}
return result.ToArray();
}
}
}