Exemplo n.º 1
0
        public override IDBResponse CreateResponse()
        {
            DeleteDocumentsResponse response = new DeleteDocumentsResponse();

            response.RequestId     = base.RequestId;
            response.IsSuccessfull = true;
            return(response);
        }
Exemplo n.º 2
0
        public static IDBResponse GetResponse(DatabaseOperationType operationTypeArg)
        {
            IDBResponse response = null;

            switch (operationTypeArg)
            {
            case DatabaseOperationType.Insert:
                response = new InsertDocumentsResponse();
                break;

            case DatabaseOperationType.Delete:
                response = new DeleteDocumentsResponse();
                break;

            case DatabaseOperationType.Get:
                response = new GetDocumentsResponse();
                break;

            case DatabaseOperationType.Update:
                response = new UpdateResponse();
                break;

            case DatabaseOperationType.ReadQuery:
                response = new ReadQueryResponse();
                break;

            case DatabaseOperationType.WriteQuery:
                response = new WriteQueryResponse();
                break;

            case DatabaseOperationType.GetChunk:
                response = new GetChunkResponse();
                break;

            case DatabaseOperationType.DisposeReader:
                response = new DatabaseResponse();
                break;

            case DatabaseOperationType.Replace:
                response = new ReplaceDocumentsResponse();
                break;

            case DatabaseOperationType.Authenticate:
                response = new AuthenticationResponse();
                break;

            case DatabaseOperationType.Init:
                response = new InitDatabaseResponse();
                break;

            default:
                throw new NotSupportedException("Operation " + operationTypeArg + " not supported");
            }
            return(response);
        }
        public object Deserialize(byte[] buffer)
        {
            //deseralize
            IDBResponse dbResponse = null;

            try
            {
                Response response = Response.ParseFrom(buffer);

                if (response != null)
                {
                    switch (response.Type)
                    {
                    case Response.Types.Type.INSERT_DOCUMENTS:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.InsertDocumentsResponse(response);
                        break;

                    case Response.Types.Type.GET_DOCUMENTS:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.GetDocumentsResponse(response);
                        break;

                    case Response.Types.Type.DELETE_DOCUMENTS:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.DeleteDocumentsResponse(response);
                        break;

                    case Response.Types.Type.UPDATE:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.UpdateResponse(response);
                        break;

                    case Response.Types.Type.WRITE_QUERY:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.WriteQueryResponse(response);
                        break;

                    case Response.Types.Type.READ_QUERY:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.ReadQueryResponse(response);
                        break;

                    case Response.Types.Type.CREATE_SESSION:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.CreateSessionResponse(response);
                        break;

                    case Response.Types.Type.GET_CHUNK:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.GetChunkResponse(response);
                        break;

                    case Response.Types.Type.DISPOSE_READER:
                        dbResponse = new DatabaseResponse(response.ToBuilder());
                        break;

                    case Response.Types.Type.REPLACE_DOCUMENTS:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.ReplaceDocumentsResponse(response);
                        break;

                    case Response.Types.Type.AUTHENTICATION:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.AuthenticationResponse(response);
                        break;

                    case Response.Types.Type.INIT_DATABASE:
                        dbResponse = new Alachisoft.NosDB.Common.Server.Engine.Impl.InitDatabaseResponse(response);
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: Deserialize Response on client Side : " + ex);
                throw;
            }

            return(dbResponse);
        }