import sys
#sys.LoadAssemblyFromFile("c:\dev\IronPython-1.0-Beta1\Tutorial\DynamicTest.dll")
sys.LoadAssemblyFromFile("DynamicTest.dll")


from DynamicTest import Base

b = Base(0)

class Extend(Base):
   def virtual_test3(self):
        return "Extend.virtual_test3" 

   def virtual_test2(self):
        return self.virtual_test3()

   def test(self):
       return "test"
 
e1 = Extend(1)
e2 = Extend(2)

print "%s == %s == %s" % (b.virtual_test1(), b.virtual_test2(), b.virtual_test3())
print "%s == %s == %s" % (e1.virtual_test1(), e1.virtual_test2(), e1.virtual_test3())
print "%s == %s == %s" % (e2.virtual_test1(), e2.virtual_test2(), e2.virtual_test3())

def newtest(self):
    return "New Method"

# This throws an exception:

# CallType = type(e1.virtual_test1)
# e1.virtual_test1 = CallType(newtest, e1)

CallType = type(e1.virtual_test3)
e1.virtual_test3 = CallType(newtest, e1)

CallType = type(e2.virtual_test3)
e2.virtual_test2 = CallType(newtest, e2)

# This works
print "%s == %s == %s" % (e1.virtual_test1(), e1.virtual_test2(), e1.virtual_test3())

# Wow! Can't call an overloaded method from C# :(
print "%s == %s" % (e2.virtual_test1(), e2.virtual_test2())


