Ejemplo n.º 1
0
 public void Init(JQuery element, AlphaTabApi context, dynamic options)
 {
     if (!context.IsTruthy())
     {
         context = new AlphaTabApi(element[0], options);
         element.Data("alphaTab", context);
         foreach (var listener in _initListeners)
         {
             listener(element, context, options);
         }
     }
 }
Ejemplo n.º 2
0
        public object Exec(Element element, string method, string[] args)
        {
            if (Script.Write <bool>("untyped __js__(\"typeof(method) != 'string'\")"))
            {
                args   = new[] { method };
                method = "init";
            }

            if (method[0] == '_' || method == "Exec")
            {
                return(null);
            }

            var         jElement = new JQuery(element);
            AlphaTabApi context  = (AlphaTabApi)jElement.Data("alphaTab");

            if (method == "destroy" && !context.IsTruthy())
            {
                return(null);
            }
            if (method != "init" && !context.IsTruthy())
            {
                throw new Error("alphaTab not initialized");
            }

            var apiMethod = Script.Write <object>("untyped __js__(\"this[method]\")");

            if (apiMethod.IsTruthy())
            {
                var realArgs = Script.Write <string[]>("untyped __js__(\"[ jElement, context ].concat(args)\")");
                return(Script.Write <object>("untyped apiMethod.apply(this, realArgs)"));
            }
            else
            {
                Logger.Error("Api", "Method '" + method + "' does not exist on jQuery.alphaTab");
                return(null);
            }
        }