Exemplo n.º 1
0
        private TiResponse removeEventListener(TiRequestParams data)
        {
            if (!data.ContainsKey("handle"))
            {
                throw new ReflectionException("\"addEventListener\" request missing \"handle\" param");
            }

            string handle   = (string)data["handle"];
            object instance = InstanceRegistry.getInstance(handle);

            if (instance == null)
            {
                throw new ReflectionException("\"addEventListener\" request invalid handle \"" + handle + "\"");
            }

            if (!data.ContainsKey("name"))
            {
                throw new ReflectionException("\"addEventListener\" request missing \"name\" param");
            }

            string   eventName = (string)data["name"];
            var      eventInfo = instance.GetType().GetEvent(eventName);
            Delegate handler   = InstanceRegistry.getDelegate(handle + "." + eventName);

            if (handler != null)
            {
                eventInfo.RemoveEventHandler(instance, handler);
                InstanceRegistry.removeDelegate(handle + "." + eventName);
            }

            return(null);
        }