Beispiel #1
0
 public Task InvokeAsync(string functionName, params object[] args)
 {
     return(_jsRuntime.MyInvokeAsync(
                "googleMapsObjectManager.invoke",
                new object[] { _guid.ToString(), functionName }
                .Concat(args).ToArray()
                ));
 }
Beispiel #2
0
 internal static Task MyInvokeAsync(
     this IJSRuntime jsRuntime,
     string identifier,
     params object[] args)
 {
     return(jsRuntime.MyInvokeAsync <object>(identifier, args));
 }
Beispiel #3
0
        private static async Task <object> InvokeAsync(
            this IJSRuntime jsRuntime,
            string identifier,
            params object[] args)
        {
            var resultObject = await jsRuntime.MyInvokeAsync <string>(identifier, args);

            object result = null;

            if (resultObject is string someText)
            {
                try
                {
                    var jo = JObject.Parse(someText);

                    if (jo.ContainsKey("dotnetTypeName"))
                    {
                        var typeName = jo.SelectToken("dotnetTypeName").Value <string>();
                        var asm      = typeof(Map).Assembly;
                        var type     = asm.GetType(typeName);
                        result = jo.ToObject(type);
                    }
                    else
                    {
                        result = someText;
                    }
                }
                catch
                {
                    result = someText;
                }
            }

            return(result);
        }
Beispiel #4
0
        public async static Task <Dictionary <Guid, JsObjectRef> > CreateMultipleAsync(
            IJSRuntime jsRuntime,
            string functionName,
            Dictionary <Guid, object> dictArgs)
        {
            Dictionary <Guid, JsObjectRef> jsObjectRefs = dictArgs.ToDictionary(e => e.Key, e => new JsObjectRef(jsRuntime, e.Key));

            await jsRuntime.MyInvokeAsync <object>(
                "googleMapsObjectManager.createMultipleObject",
                new object[] { dictArgs.Select(e => e.Key.ToString()).ToList(), functionName }
                .Concat(dictArgs.Values).ToArray()
                );

            return(jsObjectRefs);
        }
        public async static Task <JsObjectRef> CreateAsync(
            IJSRuntime jsRuntime,
            Guid guid,
            string functionName,
            params object[] args)
        {
            var jsObjectRef = new JsObjectRef(jsRuntime, guid);

            await jsRuntime.MyInvokeAsync <object>(
                "googleMapsObjectManager.createObject",
                new object[] { guid.ToString(), functionName }
                .Concat(args).ToArray()
                );

            return(jsObjectRef);
        }
Beispiel #6
0
 /// <summary>
 /// Cross browser event handler registration.
 /// This listener is removed by calling removeListener(handle) for the handle that is returned by this function.
 /// </summary>
 public Task AddDomListener(object instance, string eventName, Action handler, bool?capture)
 {
     return(_jsRuntime.MyInvokeAsync(
                "google.maps.event.addDomListener", instance, eventName, handler, capture));
 }