Exemple #1
0
        static void Main(string[] args)
        {
            global    = new DOMObject(string.Empty);
            navigator = new DOMObject("navigator");

            var httpMessageHandler = typeof(HttpClient).GetField("GetHttpMessageHandler",
                                                                 BindingFlags.Static |
                                                                 BindingFlags.NonPublic);

            var window = (JSObject)WebAssembly.Runtime.GetGlobalObject("window");

            using (var location = (JSObject)window.GetObjectProperty("location"))
            {
                BaseApiUrl = (string)location.GetObjectProperty("origin");
            }

            window = null;

            // Setup the HttpClientHandler
            httpMessageHandler.SetValue(null, (Func <HttpMessageHandler>)(() => {
                return(new WasmHttpMessageHandler());
            }));

            httpClient = new HttpClient()
            {
                BaseAddress = new Uri(BaseApiUrl)
            };
        }
Exemple #2
0
        static void Main(string[] args)
        {
            global    = new DOMObject(string.Empty);
            navigator = new DOMObject("navigator");

            using (var window = (JSObject)WebAssembly.Runtime.GetGlobalObject("window"))
                using (var location = (JSObject)window.GetObjectProperty("location"))
                {
                    BaseApiUrl = (string)location.GetObjectProperty("origin");
                }

            httpClient = new HttpClient()
            {
                BaseAddress = new Uri(BaseApiUrl)
            };
        }