title: Duplicating Code Across Multiple Namespaces and Partial Classes
body: <p>I'm using LinqToXSD to generate document models (code) based on a client's XSD's. Since these XSD's share common structure each time I generate a document model some objects get duplicated. To prevent compile problems, I've put each document model in its own namespace. This has worked great.</p>
  
  <p>But now I want to do some custom validation with these objects which are public partial classes. So I defined a <code>IValidate</code> interface with a single <code>Validate()</code> method. Now I have some low level object generated in more than one object model but each in a different namespace.</p>
  
  <pre><code>namespace1
  {
      public partial class foo : XTypedElement
         {........}
  }
  
  namespace2
  {
      public partial class foo : XTypedElement
         {........}
  }
  </code></pre>
  
  <p>Now I want to write a single partial class file to add <code>IValidate</code> interface and the <code>Validate()</code> method across all my foo classes. But, of course this won't work because they are in reality different objects. I have lots of these because of the generated code and the XSD library used to generate the code.</p>
  
  <p>If I could just shadow the internals (read the '......'s above) this would work. I have many foo's in different namespaces (and I have foo1 through foo100 each with the same issue). I need to duplicate code, I know it's a no-no and I don't want to have to do it. But, if I do, I at least do not want to have to maintain so many copies of the same code.</p>
  
  <p>I'm fairly confident this can be done with dynamics but I'd rather not have to go there.</p>
  
  <p>Can anyone suggest some other way to write these validation methods and not have to manually copy to each namespace.class's partial class?</p>