title: How do I override C# properties and methods in IronPython?
body: <p>I have an interface with a base class in C# -- I'd like to be able to implement derived classes in IronPython for embedded extensibility.</p>
  
  <p>In C# I would have something like:</p>
  
  <pre><code>public interface IInterface
  {
      bool SomeProperty { get; set; }
      bool SomeMethod(DateTime atTime);
  }
  
  public abstract class BaseClass : IInterface
  {
      public BaseClass() {}
  
      private bool someProperty = true;
      public virtual bool SomeProperty
      {
          get { return someProperty; }
          set { someProperty = value; }
      }
  
      public virtual bool SomeMethod(DateTime atTime)
      {
          return true;
      }
  }
  </code></pre>
  
  <p>Then a controller type class</p>
  
  <pre><code>public class SomeOtherClass
  {
      List&lt;IInterface&gt; interfaceCollection = new List&lt;IInterface&gt;();
  
      ... factory here to create C# classes and IPy classes derived from BaseClass or IInterface ...
  
      interfaceCollection.Add(somePytonDerivedClass);
      foreach (var intExersize in interfaceCollection)
      {
          if (intExersize.SomeProperty == true)
          {
              intExersize.SomeMethod(DateTime.Now);
          }
      }
  }
  </code></pre>
  
  <p>I'd like to do an impl in IronPython -- something like:</p>
  
  <pre><code>class BaseClassIPy (BaseClass):
  def __new__(self):
      print("Made it into the class")
      return BaseClass.__new__(self)
  
  def __init__(self):
      pass
  
  def get_SomeProperty(self):
      return BaseClass.SomeProperty
  
  def set_SomeProperty(self, value):
      BaseClass.SomeProperty = value
  
  def SomeMethod(self, atTime):
      return BaseClass.SomeMethod(atTime)
  </code></pre>
  
  <p>The <strong>new</strong> and <strong>init</strong> methods being called correctly -- </p>
  
  <p>but when I call the properties and methods on the IPy class, the calls seem to go directly to the base classes...</p>
  
  <p>Is it a syntax issue? i.e. the IPy code is wrong?</p>
  
  <p>Or am I missing something altogether?</p>
  
  <p>Regards, Chad</p>
  
  <p>---------------- Edit ----- method to inst python class:</p>
  
  <pre><code>private IInterface GetScriptPlugInNode()
  {
  
      IInterface node = null;
  
      string plugInScript = "c:\\BaseClassIPy.py";
      string plugInClass = "BaseClassIPy";
  
      var options = new Dictionary&lt;string, object&gt;();
      ScriptRuntimeSetup setup = Python.CreateRuntimeSetup(options);
      setup.HostType = typeof(SelfContainedScriptHost);  //PAL impl
      setup.DebugMode = true;
  
      var pyRuntime = new ScriptRuntime(setup);
      var engineInstance = Python.GetEngine(pyRuntime);
  
      // Redirect search path to use embedded resources
      engineInstance.SetSearchPaths(new[] { String.Empty });
  
      var scope = engineInstance.CreateScope();
  
      ScriptSource source = engineInstance.CreateScriptSourceFromFile(plugInScript);
  
      source.Execute(scope);
      var typeClass = scope.GetVariable(plugInClass);
      var instance = engineInstance.Operations.CreateInstance(typeClass);
      node = instance;
  
      return node;
  
  }
  </code></pre>