当前位置: 首页>>代码示例>>Python>>正文


Python StringTransportWithDisconnection.loseConnection方法代码示例

本文整理汇总了Python中twisted.test.proto_helpers.StringTransportWithDisconnection.loseConnection方法的典型用法代码示例。如果您正苦于以下问题:Python StringTransportWithDisconnection.loseConnection方法的具体用法?Python StringTransportWithDisconnection.loseConnection怎么用?Python StringTransportWithDisconnection.loseConnection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在twisted.test.proto_helpers.StringTransportWithDisconnection的用法示例。


在下文中一共展示了StringTransportWithDisconnection.loseConnection方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _testDataForward

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
    def _testDataForward(self, data, method="GET", body=""):
        """
        Build a fake proxy connection, and send C{data} over it, checking that
        it's forwarded to the originating request.
        """
        # Connect everything
        clientTransport = StringTransportWithDisconnection()
        serverTransport = StringTransportWithDisconnection()
        channel = DummyChannel(serverTransport)
        parent = DummyParent(channel)
        serverTransport.protocol = channel

        client = ProxyClient(method, '/foo', 'HTTP/1.0',
                             {"accept": "text/html"}, body, parent)
        clientTransport.protocol = client
        client.makeConnection(clientTransport)

        # Check data sent
        self.assertEquals(clientTransport.value(),
            "%s /foo HTTP/1.0\r\n"
            "connection: close\r\n"
            "accept: text/html\r\n\r\n%s" % (method, body))

        # Fake an answer
        client.dataReceived(data)

        # Check that the data has been forwarded
        self.assertEquals(serverTransport.value(), data)

        clientTransport.loseConnection()
        self.assertIsInstance(channel.lostReason, ConnectionDone)
开发者ID:AnthonyNystrom,项目名称:YoGoMee,代码行数:33,代码来源:test_proxy.py

示例2: CommandFailureTests

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
class CommandFailureTests(CommandMixin, TestCase):
    """
    Tests for correct failure of commands on a disconnected
    L{MemCacheProtocol}.
    """

    def setUp(self):
        """
        Create a disconnected memcache client, using a deterministic clock.
        """
        self.proto = MemCacheProtocol()
        self.clock = Clock()
        self.proto.callLater = self.clock.callLater
        self.transport = StringTransportWithDisconnection()
        self.transport.protocol = self.proto
        self.proto.makeConnection(self.transport)
        self.transport.loseConnection()


    def _test(self, d, send, recv, result):
        """
        Implementation of C{_test} which checks that the command fails with
        C{RuntimeError} because the transport is disconnected. All the
        parameters except C{d} are ignored.
        """
        return self.assertFailure(d, RuntimeError)
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:28,代码来源:test_memcache.py

示例3: TestProtocol

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
class TestProtocol(common.TestCase):

    def setUp(self):
        self.transport = StringTransportWithDisconnection()
        self.protocol = httpclient.Protocol(self, owner=None)
        self.protocol.factory = MockFactory()
        self.protocol.makeConnection(self.transport)
        self.transport.protocol = self.protocol

        self.addCleanup(self._disconnect_protocol)

    @defer.inlineCallbacks
    def testSimpleRequest(self):
        self.assertTrue(self.protocol.factory.onConnectionMade_called)
        self.assertTrue(self.protocol.is_idle())

        d = self.protocol.request(http.Methods.GET, '/',
                                  headers={'accept': 'text/html'})
        self.assertEqual('GET / HTTP/1.1\r\n'
                         'Accept: text/html\r\n\r\n', self.transport.value())

        self.assertFalse(self.protocol.is_idle())

        self.protocol.dataReceived(
            self.protocol.delimiter.join([
                "HTTP/1.1 200 OK",
                "Content-Type: text/html",
                "Content-Length: 12",
                "",
                "This is body",
                ]))
        response = yield d
        self.assertIsInstance(response, httpclient.Response)
        self.assertEqual(200, response.status)
        self.assertEqual({'content-type': 'text/html',
                          'content-length': '12'}, response.headers)
        self.assertEqual('This is body', response.body)
        self.assertTrue(self.protocol.is_idle())

        self.assertTrue(self.protocol.factory.onConnectionReset_called)

    @defer.inlineCallbacks
    def testCancelledRequest(self):
        d = self.protocol.request(http.Methods.GET, '/',
                                  headers={'accept': 'text/html'})
        d.cancel()

        self.assertFalse(self.transport.connected)
        self.assertFailure(d, httpclient.RequestCancelled)
        f = yield d
        exp = ('GET to http://10.0.0.1:12345/ was cancelled '
               '0.(\d+)s after it was sent.')
        self.assertTrue(re.match(exp, str(f)), str(f))

    def _disconnect_protocol(self):
        if self.transport.connected:
            self.transport.loseConnection()
        self.assertTrue(self.protocol.factory.onConnectionLost_called)
开发者ID:f3at,项目名称:feat,代码行数:60,代码来源:test_web_httpclient.py

示例4: test_kill

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
 def test_kill(self):
     """
     L{OneShotPortMapperFactory.kill} should return a L{Deferred} that
     will be called back when the kill request is complete.
     """
     d = self.factory.kill()
     transport = StringTransportWithDisconnection()
     proto = self.factory.buildProtocol(("127.0.01", 4369))
     proto.makeConnection(transport)
     transport.protocol = proto
     self.assertEqual(transport.value(), "\x00\x01k")
     proto.dataReceived("OK")
     transport.loseConnection()
     return d.addCallback(self.assertEqual, "OK")
开发者ID:gbour,项目名称:twotp,代码行数:16,代码来源:test_epmd.py

示例5: test_names

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
 def test_names(self):
     """
     L{OneShotPortMapperFactory.names} should return a L{Deferred} that
     will be called back when the names request is complete.
     """
     d = self.factory.names()
     transport = StringTransportWithDisconnection()
     proto = self.factory.buildProtocol(("127.0.01", 4369))
     proto.makeConnection(transport)
     transport.protocol = proto
     self.assertEqual(transport.value(), "\x00\x01n")
     proto.dataReceived("\x00\x00\x00\x01")
     proto.dataReceived("name %s at port %s\n" % ("foo", 1234))
     transport.loseConnection()
     return d.addCallback(self.assertEqual, [("foo", 1234)])
开发者ID:gbour,项目名称:twotp,代码行数:17,代码来源:test_epmd.py

示例6: _testDataForward

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
    def _testDataForward(self, code, message, headers, body, method="GET",
                         requestBody="", loseConnection=True):
        """
        Build a fake proxy connection, and send C{data} over it, checking that
        it's forwarded to the originating request.
        """
        request = DummyRequest(['foo'])

        # Connect a proxy client to a fake transport.
        clientTransport = StringTransportWithDisconnection()
        client = ProxyClient(method, '/foo', 'HTTP/1.0',
                             {"accept": "text/html"}, requestBody, request)
        clientTransport.protocol = client
        client.makeConnection(clientTransport)

        # Check data sent
        self.assertEquals(clientTransport.value(),
            "%s /foo HTTP/1.0\r\n"
            "connection: close\r\n"
            "accept: text/html\r\n\r\n%s" % (method, requestBody))

        # Fake an answer
        client.dataReceived("HTTP/1.0 %d %s\r\n" % (code, message))
        for (header, values) in headers:
            for value in values:
                client.dataReceived("%s: %s\r\n" % (header, value))
        client.dataReceived("\r\n" + body)

        # Check that the response data has been forwarded back to the original
        # requester.
        self.assertEquals(request.responseCode, code)
        self.assertEquals(request.responseMessage, message)
        receivedHeaders = list(request.responseHeaders.getAllRawHeaders())
        receivedHeaders.sort()
        expectedHeaders = headers[:]
        expectedHeaders.sort()
        self.assertEquals(receivedHeaders, expectedHeaders)
        self.assertEquals(''.join(request.written), body)

        # Check that when the response is done, the request is finished.
        if loseConnection:
            clientTransport.loseConnection()

        # Even if we didn't call loseConnection, the transport should be
        # disconnected.  This lets us not rely on the server to close our
        # sockets for us.
        self.assertFalse(clientTransport.connected)
        self.assertEquals(request.finished, 1)
开发者ID:Almad,项目名称:twisted,代码行数:50,代码来源:test_proxy.py

示例7: test_names

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
 def test_names(self):
     """
     L{Process.names} returns the list of nodes on a particular host.
     """
     d = self.process.names("spam")
     epmd = self.process.oneShotEpmds["spam"]
     transport = StringTransportWithDisconnection()
     proto = epmd.buildProtocol(("127.0.01", 4369))
     proto.makeConnection(transport)
     transport.protocol = proto
     self.assertEqual(transport.value(), "\x00\x01n")
     proto.dataReceived("\x00\x00\x00\x01")
     proto.dataReceived("name %s at port %s\n" % ("foo", 1234))
     proto.dataReceived("name %s at port %s\n" % ("egg", 4321))
     transport.loseConnection()
     return d.addCallback(self.assertEqual, [("foo", 1234), ("egg", 4321)])
开发者ID:springstar,项目名称:twotp,代码行数:18,代码来源:test_node.py

示例8: test_dump

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
 def test_dump(self):
     """
     L{OneShotPortMapperFactory.dump} should return a L{Deferred} that
     will be called back when the dump request is complete.
     """
     d = self.factory.dump()
     transport = StringTransportWithDisconnection()
     proto = self.factory.buildProtocol(("127.0.01", 4369))
     proto.makeConnection(transport)
     transport.protocol = proto
     self.assertEqual(transport.value(), "\x00\x01d")
     proto.dataReceived("\x00\x00\x00\x01")
     proto.dataReceived(
         "active name    <%s> at port %s, fd = %s\n\x00" % ("foo", 1234, 3))
     transport.loseConnection()
     return d.addCallback(
         self.assertEqual, {"active": [("foo", 1234, 3)], "old": []})
开发者ID:gbour,项目名称:twotp,代码行数:19,代码来源:test_epmd.py

示例9: TestClientProtocolReconnectionAttemps

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
class TestClientProtocolReconnectionAttemps(TestCase):
    def setUp(self):
        CONNECTION_INFO = {'username': 'satnet_admin', 'password': 'pass', 'udpipsend': '172.19.51.145',
                           'baudrate': '500000', 'name': 'Universidade de Vigo', 'parameters': 'yes',
                           'tcpportsend': '1234', 'tcpipsend': '127.0.0.1', 'udpipreceive': '127.0.0.1',
                           'attempts': '10', 'serverip': '172.19.51.143', 'serialport': '/dev/ttyUSB0',
                           'tcpportreceive': 4321, 'connection': 'udp', 'udpportreceive': 57008,
                           'serverport': 25345, 'reconnection': 'no', 'udpportsend': '57009',
                           'tcpipreceive': '127.0.0.1'}

        GS = 'VigoTest'

        gsi = GroundStationInterface(CONNECTION_INFO, GS, AMP)
        threads = object

        self.sp = client_amp.ClientProtocol(CONNECTION_INFO, gsi, threads)
        self.sp.factory = MockFactory()
        self.transport = StringTransportWithDisconnection()
        self.sp.makeConnection(self.transport)

        self.transport.protocol = self.sp

        self.correctFrame = ("00:82:a0:00:00:53:45:52:50:2d:42:30:91:1d:1b:03:" +
                             "8d:0b:5c:03:02:28:01:9c:01:ab:02:4c:02:98:01:da:" +
                             "02:40:00:00:00:10:0a:46:58:10:00:c4:9d:cb:a2:21:39")

        self.wrongFrame = 9

    def tearDown(self):
        pass

    # TODO Complete description
    def test_clientconnectionLost(self):
        """

        @return:
        """
        self.transport.loseConnection()
        return self.assertFalse(self.transport.connected)

    # TODO Complete description
    def test_clientConnectionFailed(self):
        """

        @return:
        """
        self.transport.loseConnection()
        return self.assertFalse(self.transport.connected)

    # TODO Complete description
    @patch.object(client_amp.ClientProtocol, 'callRemote')
    def test_clientEndConnection(self, callRemote):
        """

        @param callRemote:
        @return:
        """
        self.transport.loseConnection()
        self.sp.end_connection()
        return self.assertTrue(callRemote.called)
开发者ID:satnet-project,项目名称:generic-client,代码行数:62,代码来源:test_connectionDown.py

示例10: Network

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
class Network(unittest.TestCase):

    def setUp(self):
        self.proto = Redis()
        self.clock = Clock()
        self.proto.callLater = self.clock.callLater
        self.transport = StringTransportWithDisconnection()
        self.transport.protocol = self.proto
        self.proto.makeConnection(self.transport)

    def test_request_while_disconnected(self):
        # fake disconnect
        self.proto._disconnected = True

        d = self.proto.get('foo')
        self.assertFailure(d, RuntimeError)

        def checkMessage(error):
            self.assertEquals(str(error), 'Not connected')

        return d.addCallback(checkMessage)

    def test_disconnect_during_request(self):
        d1 = self.proto.get("foo")
        d2 = self.proto.get("bar")
        self.assertEquals(len(self.proto._request_queue), 2)

        self.transport.loseConnection()
        done = defer.DeferredList([d1, d2], consumeErrors=True)

        def checkFailures(results):
            self.assertEquals(len(self.proto._request_queue), 0)
            for success, result in results:
                self.assertFalse(success)
                result.trap(error.ConnectionDone)

        return done.addCallback(checkFailures)
开发者ID:djfroofy,项目名称:txRedis,代码行数:39,代码来源:test_redis.py

示例11: loseConnection

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
 def loseConnection(self):
     """
     Save the connection lost state, and forward the call.
     """
     StringTransportWithDisconnection.loseConnection(self)
     self.closed = True
开发者ID:springstar,项目名称:twotp,代码行数:8,代码来源:test_node.py

示例12: MemCacheTestCase

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]

#.........这里部分代码省略.........
        d3 = Deferred()
        self.proto.connectionLost = d3.callback

        self.clock.advance(self.proto.persistentTimeOut - 1)
        d2 = self.proto.get("bar")
        self.clock.advance(1)
        self.assertFailure(d1, TimeoutError)
        self.assertFailure(d2, TimeoutError)
        return gatherResults([d1, d2, d3])


    def test_timeoutCleanDeferreds(self):
        """
        C{timeoutConnection} cleans the list of commands that it fires with
        C{TimeoutError}: C{connectionLost} doesn't try to fire them again, but
        sets the disconnected state so that future commands fail with a
        C{RuntimeError}.
        """
        d1 = self.proto.get("foo")
        self.clock.advance(self.proto.persistentTimeOut)
        self.assertFailure(d1, TimeoutError)
        d2 = self.proto.get("bar")
        self.assertFailure(d2, RuntimeError)
        return gatherResults([d1, d2])


    def test_connectionLost(self):
        """
        When disconnection occurs while commands are still outstanding, the
        commands fail.
        """
        d1 = self.proto.get("foo")
        d2 = self.proto.get("bar")
        self.transport.loseConnection()
        done = DeferredList([d1, d2], consumeErrors=True)
        def checkFailures(results):
            for success, result in results:
                self.assertFalse(success)
                result.trap(ConnectionDone)
        return done.addCallback(checkFailures)


    def test_tooLongKey(self):
        """
        An error is raised when trying to use a too long key: the called
        command returns a L{Deferred} which fails with a L{ClientError}.
        """
        d1 = self.assertFailure(self.proto.set("a" * 500, "bar"), ClientError)
        d2 = self.assertFailure(self.proto.increment("a" * 500), ClientError)
        d3 = self.assertFailure(self.proto.get("a" * 500), ClientError)
        d4 = self.assertFailure(
            self.proto.append("a" * 500, "bar"), ClientError)
        d5 = self.assertFailure(
            self.proto.prepend("a" * 500, "bar"), ClientError)
        d6 = self.assertFailure(
            self.proto.getMultiple(["foo", "a" * 500]), ClientError)
        return gatherResults([d1, d2, d3, d4, d5, d6])


    def test_invalidCommand(self):
        """
        When an unknown command is sent directly (not through public API), the
        server answers with an B{ERROR} token, and the command fails with
        L{NoSuchCommand}.
        """
        d = self.proto._set("egg", "foo", "bar", 0, 0, "")
开发者ID:AndyPanda95,项目名称:python-for-android,代码行数:70,代码来源:test_memcache.py

示例13: PortMapperProtocolTestCase

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]

#.........这里部分代码省略.........
    def test_port2ResponseNodeNotFound(self):
        """
        Test a port2 not found response: the response deferred should be fired
        with a L{NodeNotFound} exception.
        """
        d = Deferred()
        self.proto.deferred = d
        self.proto.dataReceived("w\x01")
        self.assertEqual(self.proto.received, "")
        return self.assertFailure(d, NodeNotFound)


    def test_port2Request(self):
        """
        Test data sent by a port2 request.
        """
        d = Deferred()
        self.proto.portPlease2Request(d, "[email protected]")
        self.assertEqual(self.transport.value(), "\x00\[email protected]")
        self.assertEqual(self.proto.deferred, d)


    def test_names(self):
        """
        Test successful names request and response.
        """
        d = Deferred()
        d.addCallback(self.assertEqual, [("foo", 1234), ("egg", 4321)])
        self.proto.namesRequest(d)
        self.assertEqual(self.transport.value(), "\x00\x01n")
        self.proto.dataReceived("\x00\x00\x00\x01")
        self.proto.dataReceived("name %s at port %s\n" % ("foo", 1234))
        self.proto.dataReceived("name %s at port %s\n" % ("egg", 4321))
        self.transport.loseConnection()
        return d


    def test_dump(self):
        """
        Test successful dump request and response.
        """
        d = Deferred()
        d.addCallback(
            self.assertEqual, {"active": [("foo", 1234, 3)],
                               "old": [("egg", 4321, 2)]})
        self.proto.dumpRequest(d)
        self.assertEqual(self.transport.value(), "\x00\x01d")
        self.proto.dataReceived("\x00\x00\x00\x01")
        self.proto.dataReceived(
            "active name    <%s> at port %s, fd = %s\n\x00" % ("foo", 1234, 3))
        self.proto.dataReceived(
            "old/unused name, <%s>, at port %s, fd = %s\n\x00" % ("egg",
                                                                  4321, 2))
        self.transport.loseConnection()
        return d


    def test_kill(self):
        """
        Test successful kill request and response.
        """
        d = Deferred()
        d.addCallback(self.assertEqual, "OK")
        self.proto.killRequest(d)
        self.assertEqual(self.transport.value(), "\x00\x01k")
        self.proto.dataReceived("OK")
开发者ID:gbour,项目名称:twotp,代码行数:70,代码来源:test_epmd.py

示例14: WebSocketsProtocolWrapperTest

# 需要导入模块: from twisted.test.proto_helpers import StringTransportWithDisconnection [as 别名]
# 或者: from twisted.test.proto_helpers.StringTransportWithDisconnection import loseConnection [as 别名]
class WebSocketsProtocolWrapperTest(TestCase):
    """
    Tests for L{WebSocketsProtocolWrapper}.
    """

    def setUp(self):
        self.accumulatingProtocol = AccumulatingProtocol()
        self.protocol = WebSocketsProtocolWrapper(self.accumulatingProtocol)
        self.transport = StringTransportWithDisconnection()
        self.protocol.makeConnection(self.transport)
        self.transport.protocol = self.protocol


    def test_dataReceived(self):
        """
        L{WebSocketsProtocolWrapper.dataReceived} forwards frame content to the
        underlying protocol.
        """
        self.protocol.dataReceived(
            _makeFrame("Hello", CONTROLS.TEXT, True, mask="abcd"))
        self.assertEqual("Hello", self.accumulatingProtocol.data)


    def test_controlFrames(self):
        """
        L{WebSocketsProtocolWrapper} doesn't forward data from control frames
        to the underlying protocol.
        """
        self.protocol.dataReceived(
            _makeFrame("Hello", CONTROLS.PING, True, mask="abcd"))
        self.protocol.dataReceived(
            _makeFrame("Hello", CONTROLS.PONG, True, mask="abcd"))
        self.protocol.dataReceived(
            _makeFrame("", CONTROLS.CLOSE, True, mask="abcd"))
        self.assertEqual("", self.accumulatingProtocol.data)


    def test_loseConnection(self):
        """
        L{WebSocketsProtocolWrapper.loseConnection} sends a close frame and
        disconnects the transport.
        """
        self.protocol.loseConnection()
        self.assertFalse(self.transport.connected)
        self.assertEqual("\x88\x02\x03\xe8", self.transport.value())


    def test_write(self):
        """
        L{WebSocketsProtocolWrapper.write} creates and writes a frame from the
        payload passed.
        """
        self.accumulatingProtocol.transport.write("Hello")
        self.assertEqual("\x81\x05Hello", self.transport.value())


    def test_writeSequence(self):
        """
        L{WebSocketsProtocolWrapper.writeSequence} writes a frame for every
        chunk passed.
        """
        self.accumulatingProtocol.transport.writeSequence(["Hello", "World"])
        self.assertEqual("\x81\x05Hello\x81\x05World", self.transport.value())


    def test_getHost(self):
        """
        L{WebSocketsProtocolWrapper.getHost} returns the transport C{getHost}.
        """
        self.assertEqual(self.transport.getHost(),
                         self.accumulatingProtocol.transport.getHost())


    def test_getPeer(self):
        """
        L{WebSocketsProtocolWrapper.getPeer} returns the transport C{getPeer}.
        """
        self.assertEqual(self.transport.getPeer(),
                         self.accumulatingProtocol.transport.getPeer())


    def test_connectionLost(self):
        """
        L{WebSocketsProtocolWrapper.connectionLost} forwards the connection
        lost call to the underlying protocol.
        """
        self.transport.loseConnection()
        self.assertTrue(self.accumulatingProtocol.closed)
开发者ID:codecats,项目名称:kitty,代码行数:90,代码来源:test_websockets.py


注:本文中的twisted.test.proto_helpers.StringTransportWithDisconnection.loseConnection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。