Attention: We are retiring the ASP.NET Community Blogs. Learn more >

Oroboros and TheRing :: Provider madness

//I don't normaly write code like this, but hey I needed some levity.
/*
 <configSections>
  <section name="Oroboros"
  type="Oroboros,ProviderSamples"/>
 </configSections>
 <Oroboros type="Oroboros, ProviderSamples">
  <Tail>TheRing, ProviderSamples</Tail>
 </Oroboros>

Oroboros wurm = Oroboros.New();
Response.Write(wurm.Name);
Response.Write("<HR>");
Oroboros ring = TheRing.New();
Response.Write(ring.Name);
Response.Write("<HR>");
*/

using System;

public class TheRing : Oroboros
{
 public TheRing(Oroboros oroboros): base(oroboros){}
 new static public TheRing New()
 {
  return Oroboros.New() as TheRing;
 }
}

public class Oroboros : System.Configuration.IConfigurationSectionHandler
{
 string _tail;
 public Oroboros(){}
 public Oroboros(Oroboros oroboros){}
 public static Oroboros New()
 {
  Oroboros config = System.Configuration.ConfigurationSettings.GetConfig("Oroboros") as Oroboros;
  return Type.GetType(config.Tail).GetConstructor(new Type[1]{typeof(Oroboros)}).Invoke(new object[1]{config}) as Oroboros;
 }
 public string Tail
 {
  get
  {
   return _tail;
  }
  set
  {
   _tail = value;
  }
 } 
  
 public virtual string Name
 {
  get
  { 
   return this.GetType().Name;
  }
 }
 public object Create(object parent,object configContext,System.Xml.XmlNode section)
 {
  return new System.Xml.Serialization.XmlSerializer (Type.GetType ( section.Attributes["type"].Value )).Deserialize( new System.Xml.XmlNodeReader (section));
 }
}