/*
*
* http://mvcresourceloader.codeplex.com/license
*
* */
using System;
using System.Collections;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Security.Permissions;
using System.Web;
using System.Web.Configuration;
using System.Web.Mvc;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml;
using System.Xml.Linq;
using Everest.Library.Configuration;
using System.IO;
namespace InteSoft.Web.ExternalResourceLoader{
public sealed class LoaderConfigurationSection : System.Configuration.ConfigurationSection, IStandaloneConfigurationSection
{
private static ConfigurationProperty _propReferences;
private static ConfigurationProperty _propVersion;
private static ConfigurationProperty _propMode;
private static ConfigurationProperty _propCompact;
private static ConfigurationProperty _propCompress;
private static ConfigurationProperty _propCacheDuration;
private static ConfigurationProperty _propContent;
private static ConfigurationPropertyCollection _properties;
public LoaderConfigurationSection()
{
EnsureStaticPropertyBag();
}
private static ConfigurationPropertyCollection EnsureStaticPropertyBag()
{
if (_properties == null)
{
_propVersion = new ConfigurationProperty("version", typeof(string), "1.0", ConfigurationPropertyOptions.None);
_propMode = new ConfigurationProperty("mode", typeof(Mode), Mode.Release, ConfigurationPropertyOptions.None);
_propCompact = new ConfigurationProperty("compact", typeof(bool), true, ConfigurationPropertyOptions.None);
_propCompress = new ConfigurationProperty("compress", typeof(bool), true, ConfigurationPropertyOptions.None);
_propCacheDuration = new ConfigurationProperty("cacheDuration", typeof(int), 30, ConfigurationPropertyOptions.None);
_propReferences = new ConfigurationProperty("references", typeof(ReferenceCollection), null, ConfigurationPropertyOptions.IsDefaultCollection | ConfigurationPropertyOptions.IsRequired);
_propContent = new ConfigurationProperty("schemes", typeof(SchemeCollection), null, ConfigurationPropertyOptions.IsDefaultCollection | ConfigurationPropertyOptions.IsRequired);
ConfigurationPropertyCollection propertys = new ConfigurationPropertyCollection
{
_propReferences,
_propVersion,
_propMode,
_propCompact,
_propCompress,
_propCacheDuration,
_propContent
};
_properties = propertys;
}
return _properties;
}
protected override ConfigurationPropertyCollection Properties
{
get { return EnsureStaticPropertyBag(); }
}
[ConfigurationProperty("version", DefaultValue = "1.0")]
public string Version
{
get { return (string)base[_propVersion]; }
set { base[_propVersion] = value; }
}
[ConfigurationProperty("mode", DefaultValue = ExternalResourceLoader.Mode.Release)]
public Mode Mode
{
get { return (Mode)base[_propMode]; }
set { base[_propMode] = value; }
}
[ConfigurationProperty("compact", DefaultValue = true)]
public bool Compact
{
get { return (bool)base[_propCompact]; }
set { base[_propCompact] = value; }
}
[ConfigurationProperty("compress", DefaultValue = true)]
public bool Compress
{
get { return (bool)base[_propCompress]; }
set { base[_propCompress] = value; }
}
[ConfigurationProperty("cacheDuration", DefaultValue = 30)]
public int CacheDuration
{
get { return (int)base[_propCacheDuration]; }
set { base[_propCacheDuration] = value; }
}
[ConfigurationProperty("references", IsDefaultCollection = true)]
public ReferenceCollection References
{
get { return (ReferenceCollection)base[_propReferences]; }
}
[ConfigurationProperty("schemes", IsDefaultCollection = true)]
public SchemeCollection Schemes
{
get { return (SchemeCollection)base[_propContent]; }
}
public void DeserializeSection(string config)
{
this.DeserializeSection(new XmlTextReader(new StringReader(config)));
}
}
}
|