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


C# IOperation.Request方法代码示例

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


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

示例1: ExecuteOperationInternal

        private ODocument ExecuteOperationInternal(IOperation operation)
        {
            try
            {
                if (_networkStream == null)
                    Reconnect();

                var req = new Request(this);
                req.SetSessionId(SessionId);

                Request request = operation.Request(req);
                byte[] buffer;

                foreach (RequestDataItem item in request.DataItems)
                {
                    switch (item.Type)
                    {
                        case "byte":
                        case "short":
                        case "int":
                        case "long":
                            Send(item.Data);
                            break;
                        case "record":
                            buffer = new byte[2 + item.Data.Length];
                            Buffer.BlockCopy(BinarySerializer.ToArray(item.Data.Length), 0, buffer, 0, 2);
                            Buffer.BlockCopy(item.Data, 0, buffer, 2, item.Data.Length);
                            Send(buffer);
                            break;
                        case "bytes":
                        case "string":
                        case "strings":
                            Send(BinarySerializer.ToArray(item.Data.Length));
                            Send(item.Data);
                            break;
                        default:
                            break;
                    }
                }

                _networkStream.Flush();

                if (request.OperationMode != OperationMode.Synchronous)
                    return null;

                Response response = new Response(this);
                response.Receive();
                return ((IOperation)operation).Response(response);
            }
            catch (IOException)
            {
                Destroy();
                throw;
            }
        }
开发者ID:emman-ok,项目名称:OrientDB-NET.binary,代码行数:55,代码来源:Connection.cs

示例2: ExecuteOperation

        internal ODocument ExecuteOperation(IOperation operation)
        {
            Request request = operation.Request(SessionId);
            byte[] buffer;

            foreach (RequestDataItem item in request.DataItems)
            {
                switch (item.Type)
                {
                    case "byte":
                    case "short":
                    case "int":
                    case "long":
                        Send(item.Data);
                        break;
                    case "record":
                        buffer = new byte[2 + item.Data.Length];
                        Buffer.BlockCopy(BinarySerializer.ToArray(item.Data.Length), 0, buffer, 0, 2);
                        Buffer.BlockCopy(item.Data, 0, buffer, 2, item.Data.Length);
                        Send(buffer);
                        break;
                    case "bytes":
                    case "string":
                    case "strings":
                        //buffer = new byte[4 + item.Data.Length];
                        //Buffer.BlockCopy(BinarySerializer.ToArray(item.Data.Length), 0, buffer, 0, 4);
                        //Buffer.BlockCopy(item.Data, 0, buffer, 4, item.Data.Length);
                        //Send(buffer);

                        Send(BinarySerializer.ToArray(item.Data.Length));
                        Send(item.Data);
                        break;
                    default:
                        break;
                }
            }

            _networkStream.Flush();

            if (request.OperationMode == OperationMode.Synchronous)
            {
                try
                {
                    Response response = new Response(this);

                    response.Receive();

                    return ((IOperation)operation).Response(response);
                }
                catch (Exception )
                {
                    //reset connection as the socket may contains unread data and is considered unstable
                    Reconnect();
                    throw;
                }
            }
            else
            {
                return null;
            }
        }
开发者ID:workshare,项目名称:OrientDB-NET.binary,代码行数:61,代码来源:Connection.cs


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