Example #1
0
    def testInterfaceProperty(self):
        """Test properties of interfaces. Added after a bug report
           that an IsAbstract check was inappropriate and prevented
           use of properties when only the interface is known."""

        from System.Collections import Hashtable, ICollection
        mapping = Hashtable()
        coll = ICollection(mapping)
        self.failUnless(coll.Count == 0)
Example #2
0
    def test_classes(self):
        from System.Collections import Hashtable
        from Python.Test import StringDelegate

        self.notify("Running class leak check...")

        for i in range(self.count):
            if i == 10:
                self.start_test()

            # Reference type
            x = Hashtable()
            del x

            # Value type
            x = System.Int32(99)
            del x

            # Delegate type
            x = StringDelegate(hello_func)
            del x

        self.end_test()
Example #3
0
 def __setitem__(self, key, value):
     value = 'my ' + str(value)
     Hashtable.__setitem__(self, key, value)
Example #4
0
 def __getitem__(self, key):
     value = Hashtable.__getitem__(self, key)
     return 'my ' + str(value)
Example #5
0
 def __setitem__(self, key, value):
     value = 'my ' + str(value)
     Hashtable.__setitem__(self, key, value)
Example #6
0
 def __getitem__(self, key):
     value = Hashtable.__getitem__(self, key)
     return 'my ' + str(value)
import sys;
import clr;
#load hash table
from System.Collections import Hashtable;
#HybridDictionary
from System.Collections.Specialized import HybridDictionary;
from System.Collections.Specialized import StringCollection;

#create object
print "---------------Hashtable------------"
m_hashTbl = Hashtable();

m_hashTbl["a"] = "t1";
m_hashTbl["b"] = "t2";
m_hashTbl["d"] = "t3";

for key in m_hashTbl.Keys :
    print "hash value :", m_hashTbl[key];


#string collection
print "---------------String Collections------------"
strBuffer = StringCollection()

strBuffer.Add("abc");
strBuffer.Add("def");
strBuffer.Add("Alpha");

for str in strBuffer :
    print "string :", str;