예제 #1
0
        internal object Invoke(object evt)
        {
            var eventArgs = new HtmlEventArgs();

            if (evt != null)
            {
                var dict = (IDictionary <string, object>)((object[])evt)[0];
                ScriptObjectHelper.DictionaryToScriptableType(dict, eventArgs);
            }

            EventHandlers?.Invoke(this.Source, eventArgs);

            if (EventHandlers == null)
            {
                try
                {
                    var eventDelegate = (MulticastDelegate)Source.GetType().GetField(EventName, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).GetValue(Source);
                    eventDelegate.DynamicInvoke(new object[] { Source, EventArgs.Empty });
                }
                catch (Exception exc)
                {
                    // We get an exception if there is nothing to invoke
                    Console.WriteLine($"exception {exc.Message}");
                }
            }
            return(null);
        }
예제 #2
0
        public async Task <Location> GetLocation()
        {
            var location = await GetPropertyAsync <object>("location");

            if (location != null)
            {
                var loc = new Location();
                ScriptObjectHelper.DictionaryToScriptableType((IDictionary <string, object>)location, loc);
                return(loc);
            }
            return(default(Location));
        }