コード例 #1
0
        // -----------------------------------------------------------------------------------------------------------------------
        // Get Element by XPath - using JS injection and wgxpath code
        // -----------------------------------------------------------------------------------------------------------------------

        public mshtml.IHTMLElement GetElementByXPath(string Xpath)
        {
            mshtml.HTMLDocument doc = (mshtml.HTMLDocument)browser.Document;

            //Check if it is better to create temp js file instead of pushing the whole code to the html doc
            //TODO: inject only once
            var v = doc.body.getAttribute("data-GingerXpath");

            if (v is System.DBNull)
            {
                injectScriptCode(doc, JavaScriptHandler.GetJavaScriptFileContent(JavaScriptHandler.eJavaScriptFile.wgxpath_install));
                string js = GetXpathJS();
                injectScriptCode(doc, js);
                doc.body.setAttribute("data-GingerXpath", "Done");
            }
            var elem = GetHtmlElement(Xpath);

            return(elem);
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AcxiomTabViewModel"/> class.
        /// </summary>
        public AcxiomTabViewModel(IAcxiomTabView view,
                                  IIntentManager intentManager,
                                  IDispatcherTimer dispatcherTimer,
                                  IDependencyInjectionContainer container,
                                  IAcxiomConstants acxiomConstants)
            : base(isCloseable: true)
        {
            mIntentManager   = intentManager;
            mContainer       = container;
            mDispatcherTimer = dispatcherTimer;
            mAcxiomConstants = acxiomConstants;
            Header           = AcxiomStringResources.TabHeader;        //Tab Header text
            HeaderTooltip    = AcxiomStringResources.TabHeaderTooltip; //Tab header tooltip

            mBaseURL           = mAcxiomConstants.ExternalSubsetGenerationUri.ToString();
            PageLocation       = mBaseURL;
            mJavaScriptHandler = new JavaScriptHandler(this);

            SetAsViewModelForView(view);
            //All is ok, start to render html UI
            mDispatcherTimer.Interval = TimeSpan.FromMilliseconds(100);
            mDispatcherTimer.Tick    += CheckForHtmlReady;
            mDispatcherTimer.Start();
        }
コード例 #3
0
        public async Task InvokeAsync(HttpContext context, PathHandler pathHandler)
        {
            var path = context.Request.Path;

            if (path == scriptPath)
            {
                context.Response.Headers.Add("Content-Type", "text/javascript;charset=UTF-8");
                await context.Response.WriteAsync(JsContent.allContent);

                return;
            }

            if (path.StartsWithSegments(startPath))
            {
                string body = "";
                using (var stream = new StreamReader(context.Request.Body))
                {
                    body = stream.ReadToEnd();
                }

                var result = pathHandler.Execute(path.Value.Substring(startPath.Length + 1), JavaScriptHandler.Create(body));
                if (result)
                {
                    if (result.Data == null)
                    {
                        context.Response.StatusCode = 204;
                    }
                    else
                    {
                        context.Response.StatusCode = 200;
                        await context.Response.WriteAsync(JsonConvert.SerializeObject(result.Data));
                    }
                }
                else
                {
                    context.Response.StatusCode = 404;
                }
                return;
            }

            await _Next(context);

            //var found = pathMappings[context.Request.Path];
            //if (found == null) await _Next(context);
            //else
            //{
            //    found(context);
            //}
        }
コード例 #4
0
        public static string wgxpath_install()
        {
            string script = JavaScriptHandler.GetJavaScriptFileContent(JavaScriptHandler.eJavaScriptFile.wgxpath_install);

            return(script);
        }
コード例 #5
0
        public static string GetGingerHTMLHelper()
        {
            string script = JavaScriptHandler.GetJavaScriptFileContent(JavaScriptHandler.eJavaScriptFile.GingerHTMLHelper);

            return(script);
        }
コード例 #6
0
        public static string GetJquery()
        {
            string script = JavaScriptHandler.GetJavaScriptFileContent(JavaScriptHandler.eJavaScriptFile.jquery_min);

            return(script);
        }
コード例 #7
0
 public StronglyScriptsTagHelper(IServiceProvider service)
 {
     data    = service.GetService <JavaScriptData>();
     handler = service.GetService <JavaScriptHandler>();
 }