public void OpenDocument(string host, DocumentDto documentDto)
 {
     using (var cf = GetChannelFactory(host))
     {
         cf.CreateChannel().OpenDocument(documentDto);
     }
 }
 public void OpenDocument(DocumentDto dto)
 {
     //we ignore requests if we are not waiting for such a document
     if (_pendingDocumentRequests.Contains(dto.DocumentId))
     {
         AddDocument(dto);
         _editor.UpdateText(dto.DocumentId, dto.Content);
         _pendingDocumentRequests.Remove(dto.DocumentId);
     }
 }
        private void AddDocument(DocumentDto dto)
        {
            var hash = GetHash(dto.Content);
            var document = new Document
            {
                Id = dto.DocumentId,
                CurrentRevisionId = dto.RevisionId,
                CurrentHash = hash,
                Owner = dto.Owner,
                OwnerHost = dto.OwnerHost,
                Content = dto.Content,

            };
            if (dto.Owner == _memberName)
            {
                document.AddRevision(new Revision
                {
                    Id = dto.RevisionId,
                    Content = document.Content,
                    UpdateDto = new UpdateDto
                    {
                        MemberName = _memberName,
                        MemberHost = _serverHost,
                        PreviousRevisionId = 0,
                        PreviousHash = new byte[] {},
                        NewHash = hash,
                        NewRevisionId = dto.RevisionId,
                        Patch = new List<Patch>(),
                    }
                });
                _editor.UpdateNumberOfEditors(document.Id, document.EditorCount);
            }
            else
            {
                _editor.UpdateNumberOfEditors(document.Id, dto.EditorCount);
            }

            _documents.Add(dto.DocumentId, document);
        }