|
#region Using Directives
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Xml;
using Composite.Layout.Properties;
#endregion
namespace Composite.Layout.Configuration
{
public class LayoutProviderSection : IConfigurationSectionHandler
{
#region IConfigurationSectionHandler Members
public object Create(object parent, object configContext, XmlNode section)
{
var name = section.Attributes["name"].Value;
var type = section.Attributes["type"].Value;
var values = new NameValueCollection();
foreach (XmlAttribute attribute in section.Attributes)
{
values.Add(attribute.Name, attribute.Value);
}
if (section.ChildNodes.Count > 0)
{
values.Add("InnerXml", section.InnerXml);
}
var providerType = Type.GetType(type);
var layoutProvider = AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(providerType.Assembly.CodeBase, providerType.FullName, null) as LayoutProviderBase;
if (layoutProvider == null)
{
throw new NullReferenceException(Resources.NullLayoutProviderErrorMessage);
}
layoutProvider.Initialize(name, values);
return layoutProvider;
}
#endregion
}
}
|
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.
I'm a software developer living in Northampton, UK, and enjoy working with the latest .Net technologies.