IDescription interface using generics and extension methods
<p>I am trying to implement an IDescription Interface. Basic purpose of this interface is that I have many different classes that have a list of multilingual descriptions and I want the the basic AddDescription EditDescription and some other basic behaviours to be defined by the interface and not implemented by the classes individually that inherits the interface. I am trying to assign the behavior to the interface using extension methods.</p>

<p>I have some road blocks such as how do I access the descriptions collection of the entity that I am passing on to the IDescription interface (entity.Descriptions.Add)? </p>

<p>I am very new to generics, extension methods, anonymous types etc so please bear with me with my misunderstandings of how these are used. Will appreciate if you can help me correct the below code. I wrote it to give the idea of what I am trying to achieve, it obviously fundamental errors in it. Thanks</p>

<pre><code>public class Company : IDescription&lt;Company, CompanyDescription&gt;
{
   public IList&lt;CompanyDescription&gt; Desriptions { get; set; }
}

public class Location : IDescription&lt;Location, LocationDescription&gt;
{
   public IList&lt;LocationDescription&gt; Desriptions { get; set; }
}


public interface IDescription&lt;eT, dT&gt;
{
   void AddDescription(eT, string text);
   void EditDescription(eT, dT, string text);
} 

public static DescriptionInterfaceExtensions
{

   public static void AddDescription(this IDescription&lt;eT, dT&gt; description, eT entity, string text)
   {
      dT newDescription = new dT(text);
      entity.Descriptions.Add(newDescription);
   }
}
</code></pre>
