Example #1
0
 def serialize(self, sock: BinarySocketWriter):
     """
     Serialize message
     """
     super().serialize(sock)
     sock.writeInt32(self.objectId)
     sock.writeString(self.property)
     CLRMessage.write(sock, CLRMessage.createByObj(self.setval))
Example #2
0
    def getIndexed(self, objectId: int, idx: int):
        """
        get indexed on CLR-side object (this is only used internally)

        :param objectId: object ID of previously created object
        :param idx: index to retrieve
        """
        ## create object request
        req = CLRGetIndexed(objectId, idx)
        CLRMessage.write(self.cout, req)

        ## process result
        rep = CLRMessage.read(self.cin)
        return rep.toValue()
Example #3
0
    def getProperty(self, objectId: int, property: str):
        """
        get property on CLR-side object (this is only used internally)

        :param objectId: object ID of previously created object
        :param property: name of property to get
        """
        ## create object request
        req = CLRGetProperty(objectId, property)
        CLRMessage.write(self.cout, req)

        ## process result
        rep = CLRMessage.read(self.cin)
        return rep.toValue()
Example #4
0
    def new(self, classname: str, *args):
        """
        create a new CLR object

        :param classname: fully qualified or partially qualified class name (i.e. 'com.stg.models.MyClass' or 'MyClass')
        :param *args: optional arguments to the constructor
        """
        ## create object request
        req = CLRCreateObject(classname, args)
        CLRMessage.write(self.cout, req)

        ## process result
        rep = CLRMessage.read(self.cin)
        return rep.toValue()
Example #5
0
    def call(self, objectId: int, methodname: str, *args):
        """
        call method on CLR-side object (this is only used internally)

        :param objectId: object ID of previously created object
        :param methodname: name of method / function to call
        :param *args: arguments to method / function        
        """
        ## create object request
        req = CLRCallMethod(objectId, methodname, args)
        CLRMessage.write(self.cout, req)

        ## process result
        rep = CLRMessage.read(self.cin)
        return rep.toValue()
Example #6
0
    def callstatic(self, classname: str, methodname: str, *args):
        """
        call class method on CLR-side object

        :param classname: fully qualified or partially qualified class name (i.e. 'com.stg.models.MyClass' or 'MyClass')
        :param methodname: name of method / function to call
        :param *args: arguments to method / function
        """
        ## create object request
        req = CLRCallStaticMethod(classname, methodname, args)
        CLRMessage.write(self.cout, req)

        ## process result
        rep = CLRMessage.read(self.cin)
        return rep.toValue()
Example #7
0
    def classFor(self, classname: str):
        """
        get class template for named type (this is only used internally)
        """
        klass = CLRApi.Classes.get(classname, None)
        if klass is not None:
            return klass
        else:
            ## create request
            req = CLRTemplateReq(classname)
            CLRMessage.write(self.cout, req)

            ## process result
            rep = CLRMessage.read(self.cin)
            info = rep.toValue()
            klass = CLRObject.proxyClassFor(classname, info)
            CLRApi.Classes[classname] = klass
            return klass
Example #8
0
 def release(self, objectId: int):
     """
     release an object for GC (this is only used internally)
     """
     req = CLRRelease(objectId)
     CLRMessage.write(self.cout, req)