Пример #1
0
        private RemoteTaskResult InnerPerformTask(RemoteTask task)
        {
            EnsureXulInit();

            // TODO inject GeckoFX Dependencies
            using (var captureEngine = new GeckoCaptureEngine(task.BrowserSize, task.GetTrigger(), task.GetCaptureZone())
            {
                AcceptLanguages = task.AcceptLanguages,
                UserAgent = task.UserAgent
            })
            {
                if (task.Cookies != null)
                {
                    foreach (var cookie in task.Cookies)
                    {
                        captureEngine.Cookies.Add(cookie);
                    }
                }

                using (var captureResult = captureEngine.CaptureUrl(task.Url, task.Timeout))
                {
                    var taskResult = new RemoteTaskResult();

                    using (var memoryStream = new MemoryStream())
                    {
                        captureResult.Save(memoryStream, ImageFormat.Png);
                        taskResult.PayLoad = memoryStream.ToArray();
                    }


                    return(taskResult);
                }
            }
        }