protected void SetPropertyValues(IAnnotation annotation, DataAdapterDependencies dataAdapterDependencies)
            {
                CreatedOn        = annotation.CreatedOn;
                CreatedOnDisplay = CreatedOn.ToString(DateTimeClientFormat);
                var text = annotation.NoteText;

                Text            = AnnotationHelper.FormatNoteText(text).ToString();
                UnformattedText = text.Replace(AnnotationHelper.WebAnnotationPrefix, string.Empty);
                if (annotation.FileAttachment != null)
                {
                    AttachmentFileName    = annotation.FileAttachment.FileName;
                    HasAttachment         = annotation.FileAttachment != null;
                    AttachmentContentType = annotation.FileAttachment.MimeType;
                    AttachmentUrl         = HasAttachment
                                                ? annotation.Entity.GetFileAttachmentUrl(dataAdapterDependencies.GetWebsite())
                                                : string.Empty;
                    AttachmentSize        = annotation.FileAttachment.FileSize;
                    AttachmentSizeDisplay = AttachmentSize.ToString();
                    AttachmentIsImage     = HasAttachment &&
                                            (new List <string> {
                        "image/jpeg", "image/gif", "image/png"
                    }).Contains(AttachmentContentType);
                }
                var subject = annotation.Subject;

                Subject   = subject;
                IsPrivate = AnnotationHelper.GetNotePrivacy(annotation);
                var noteContact = AnnotationHelper.GetNoteContact(subject);
                var user        = dataAdapterDependencies.GetPortalUser();

                IsPostedByCurrentUser = noteContact != null && user != null && noteContact.Id == user.Id;
                PostedByName          = noteContact == null?AnnotationHelper.GetNoteCreatedByName(annotation) : noteContact.Name;

                if (CanWrite)
                {
                    CanWrite = IsPostedByCurrentUser;
                }
                if (CanDelete)
                {
                    CanDelete = IsPostedByCurrentUser;
                }
                DisplayToolbar = CanWrite || CanDelete;
            }
        public void TestReciveSendMessageBlockWcf()
        {
            const string BaseAddress     = "http://*****:*****@"<s:Envelope xmlns:s=""http://www.w3.org/2003/05/soap-envelope"">
                                <s:Header />
                                <s:Body>
                                    <AcceptMessageResponse xmlns=""http://tempuri.org/"" />
                                </s:Body>
                            </s:Envelope>"));
                        });
                    }))
                    {
                        int timeout = sendingManager.ScanningPeriodMilliseconds + SendTimeout;

                        var recievingThread = new Thread(asyncReciever.AsyncRecieve);

                        sendingManager.Prepare();
                        sendingManager.Start();

                        try
                        {
                            var sw = new Stopwatch();

                            bool sendingStarted = false;
                            int  n = 0;

                            recievingThread.Start();

                            while (true)
                            {
                                var now = DateTime.Now;

                                // wait for the callback
                                resetEvent.WaitOne(timeout);

                                // synchronous waiting time measurement
                                double waitingTime = (DateTime.Now - now).TotalMilliseconds;

                                if (!sendingStarted)
                                {
                                    timeout        = SendTimeout;
                                    sendingStarted = true;
                                    sw.Start();
                                }

                                if (exception != null)
                                {
                                    throw exception;
                                }

                                var sendedCount = sendedMessages.Count;

                                if (sendedCount > BlockSize)
                                {
                                    // the test will fail at Assert block
                                    break;
                                }

                                if (sendedCount == n)
                                {
                                    if (waitingTime < SendTimeout)
                                    {
                                        continue;
                                    }

                                    if (sendedCount < BlockSize)
                                    {
                                        throw new TimeoutException($"{dataService.ToString()}. Время ожидания callback-вызова превысило {SendTimeout} мсек.");
                                    }

                                    // the test result will be determined at Assert block
                                    break;
                                }

                                n = sendedCount;
                            }

                            sw.Stop();
                            sendingTime = sw.Elapsed.TotalMilliseconds - SendTimeout;
                        }
                        catch (Exception ex)
                        {
                            asyncReciever.SetStopFlag();
                            exception = exception ?? ex;
                        }
                        finally
                        {
                            sendingManager.Stop();
                            sendingManager.AfterStop();
                        }

                        recievingThread.Join();

                        if (exception != null)
                        {
                            throw exception;
                        }
                    }

                // Assert.
                Assert.False(sendedMessages.Count > BlockSize, $"{ dataService.ToString()}. Количество отправленных сообщений превысило количество полученных сообщений.");

                var diagnosticMessage = $"{dataService.ToString()}:";
                diagnosticMessage += $"{Environment.NewLine}  Recieving time {asyncReciever.RecievingTime.ToString()} ms.";
                diagnosticMessage += $"{Environment.NewLine}  Sending time {sendingTime.ToString()} ms.";
                Console.WriteLine(diagnosticMessage);
            }
        }