Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7980607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:07:31+00:00 2026-06-04T10:07:31+00:00

I have an interface with a base class in C# — I’d like to

  • 0

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.

In C# I would have something like:

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;
    }
}

Then a controller type class

public class SomeOtherClass
{
    List<IInterface> interfaceCollection = new List<IInterface>();

    ... 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);
        }
    }
}

I’d like to do an impl in IronPython — something like:

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)

The new and init methods being called correctly —

but when I call the properties and methods on the IPy class, the calls seem to go directly to the base classes…

Is it a syntax issue? i.e. the IPy code is wrong?

Or am I missing something altogether?

Regards, Chad

—————- Edit —– method to inst python class:

private IInterface GetScriptPlugInNode()
{

    IInterface node = null;

    string plugInScript = "c:\\BaseClassIPy.py";
    string plugInClass = "BaseClassIPy";

    var options = new Dictionary<string, object>();
    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;

}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T10:07:33+00:00Added an answer on June 4, 2026 at 10:07 am

    You have to change the interface property/method in your abstract base class to be virtual in order to allow the IronPython class to properly inherit from that.

    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;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an interface with several events I have base class implementing the interface
I have an interface so class writers are forced to implement certain methods. I
I have an interface for a base class, and every class that inherits from
Suppose I have an interface called Interface, and a concrete class called Base, which,
I have an interface IServiceInfo and an abstract class ServiceInfo. There are several classes
I have subclassed NSMutableArray as follows: Base Class: @interface MyBaseMutableArray : NSMutableArray { //
I'd like to define an interface and abstract base class for a set of
I have two Objective-C classes and one is derived from the other as @interface
I have this base class having the following interface: abstract class Base { abstract
I have an interface I that is implemented by a base class B. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.