Example #1
0
        public void OnPreviewToolRegistrationReceivedFromWebApp(Regex regex)
        {
            lock (this)
            {
                previewPartIdRegex = regex;

                if (lastContentUpdateRequest != null)
                {
                    var contentUpdateParams = lastContentUpdateRequest.ConvertRequestToContentUpdateParams(previewPartIdRegex);
                    if (contentUpdateParams.PreviewParts.Length > 0)
                    {
                        var postMessage = new ContentUpdateMessage(contentUpdateParams).SerializeToPostMessage();
                        executeJavaScriptAsync(postMessage);
                        lastContentUpdateRequest = null;
                    }

                    if (lastChangeHighlightRequest != null)
                    {
                        var changeHighlightParams = lastChangeHighlightRequest.ConvertRequestToChangeHighlightParams(previewPartIdRegex);
                        if (changeHighlightParams.ActivePreviewParts.Length > 0)
                        {
                            var postMessage = new ChangeHighlightInPreviewMessage(changeHighlightParams).SerializeToPostMessage();
                            executeJavaScriptAsync(postMessage);
                            lastChangeHighlightRequest = null;
                        }
                    }
                }
                else
                {
                    requestPreviewPartIdUpdate();
                }
            }
        }
Example #2
0
        public void HandleContentUpdateRequest(ContentUpdateRequestFromMQ contentUpdateRequest)
        {
            lock (this)
            {
                if (externalToolAddress == null)
                {
                    foreach (var previewPart in contentUpdateRequest.PreviewParts)
                    {
                        if (updateExternalToolAddress(previewPart.PreviewProperties))
                        {
                            break;
                        }
                    }
                }

                if (previewPartIdRegex != null)
                {
                    var contentUpdateParams = contentUpdateRequest.ConvertRequestToContentUpdateParams(previewPartIdRegex);
                    if (contentUpdateParams.PreviewParts.Length > 0)
                    {
                        var postMessage = new ContentUpdateMessage(contentUpdateParams).SerializeToPostMessage();
                        executeJavaScriptAsync(postMessage);
                    }

                    if (lastChangeHighlightRequest != null)
                    {
                        var changeHighlightParams = lastChangeHighlightRequest.ConvertRequestToChangeHighlightParams(previewPartIdRegex);
                        if (changeHighlightParams.ActivePreviewParts.Length > 0)
                        {
                            var postMessage = new ChangeHighlightInPreviewMessage(changeHighlightParams).SerializeToPostMessage();
                            executeJavaScriptAsync(postMessage);
                            lastChangeHighlightRequest = null;
                        }
                    }
                }
                else
                {
                    lastContentUpdateRequest = contentUpdateRequest;
                }
            }
        }