// Copyright (C) 2007, 2008 @UKPLC
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
using System.Configuration;
namespace SLiNgshoT.Core
{
public enum Versions
{
NET_1_1 = 11,
NET_2_0 = 20
}
public class Configuration : ConfigurationSection
{
#region public properties
[ConfigurationProperty("buildConfiguration", IsRequired = true, IsKey = false)]
public string BuildConfiguration
{
get { return (string)this["buildConfiguration"]; }
}
[ConfigurationProperty("outputPath", IsRequired = true, IsKey = false)]
public string OutputPath
{
get { return (string)this["outputPath"]; }
}
[ConfigurationProperty("appConfiguration", IsRequired = true, IsKey = false)]
public string AppConfiguration
{
get { return (string)this["appConfiguration"]; }
}
[ConfigurationProperty("libraries", IsRequired = false, IsKey = false)]
[ConfigurationCollection(typeof(LibrariesCollection))]
public LibrariesCollection Libraries
{
get { return (LibrariesCollection)this["libraries"]; }
}
[ConfigurationProperty("includes", IsRequired = true, IsKey = false)]
[ConfigurationCollection(typeof(IncludesCollection))]
public IncludesCollection Includes
{
get { return (IncludesCollection)this["includes"]; }
}
[ConfigurationProperty("excludes", IsRequired = false, IsKey = false)]
[ConfigurationCollection(typeof(ExcludesCollection))]
public ExcludesCollection Excludes
{
get { return (ExcludesCollection)this["excludes"]; }
}
#endregion
#region static methods
private const string CS_SECTION = "slingshot";
private static Configuration _Current;
public static Configuration Current
{
get
{
if (_Current == null)
{
System.Configuration.Configuration config;
config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
_Current = (Configuration)config.Sections[CS_SECTION];
}
return _Current;
}
}
#endregion
}
public class LibrariesCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new Library();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((Library)element).Name;
}
private string _OutputPath = null;
[ConfigurationProperty("outputPath", IsRequired = true, IsKey = false)]
public string OutputPath
{
get { return _OutputPath; }
}
}
public class Library : ConfigurationElement
{
[ConfigurationProperty("path", IsRequired = true, IsKey = false)]
public string Path
{
get { return (string)this["path"]; }
}
[ConfigurationProperty("name", IsRequired = true, IsKey = true)]
public string Name
{
get { return (string)this["name"]; }
}
}
public class IncludesCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new Include();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((Include) element).Path;
}
}
public class Include : ConfigurationElement
{
[ConfigurationProperty("path", IsRequired = true, IsKey = true)]
public string Path
{
get { return (string)this["path"]; }
}
[ConfigurationProperty("version", IsRequired = false, DefaultValue = Versions.NET_1_1, IsKey = false)]
public Versions Version
{
get { return (Versions)this["version"]; }
}
[ConfigurationProperty("net2WebProject", IsRequired = false, DefaultValue = false, IsKey = false)]
public bool Net2WebProject
{
get { return (bool)this["net2WebProject"]; }
}
[ConfigurationProperty("outputPath", IsRequired = false, DefaultValue = null, IsKey = false)]
public string OutputPath
{
get { return (string)this["outputPath"]; }
}
[ConfigurationProperty("appConfiguration", IsRequired = false, DefaultValue = null, IsKey = false)]
public string AppConfiguration
{
get { return (string)this["appConfiguration"]; }
}
[ConfigurationProperty("recursive", IsRequired = false, DefaultValue = true, IsKey = false)]
public bool Recursive
{
get { return (bool)this["recursive"]; }
}
}
public class ExcludesCollection : ConfigurationElementCollection
{
protected override ConfigurationElement CreateNewElement()
{
return new Exclude();
}
protected override object GetElementKey(ConfigurationElement element)
{
return ((Exclude) element).Expression;
}
}
public class Exclude : ConfigurationElement
{
[ConfigurationProperty("expression", IsRequired = true, IsKey = true)]
public string Expression
{
get { return (string)this["expression"]; }
}
}
}