Exemple #1
0
        /// <summary>
        /// Install Routes from the specified class
        /// </summary>
        /// <param name="addonClass">The class that will be looked up</param>
        private void RegisterRoutes(KodiAddon addon)
        {
            Type addonClass = addon.GetType();

            Routes.Clear();
            Console.WriteLine("REGISTER ROUTES");

            var methods = addonClass.GetMethods().Where(m => Attribute.IsDefined(m, typeof(RouteAttribute), false));

            Console.WriteLine("Num Attribs: {0}", methods.Count());
            foreach (var method in addonClass.GetMethods())
            {
                var attributes = method.GetCustomAttributes(typeof(RouteAttribute), false);
                if (attributes.Length > 0)
                {
                    RouteAttribute route = attributes[0] as RouteAttribute;

                    string url = RemoveTrailingSlash(route.Url);
                    // Delegate from Class instance
                    RouteCallback callback = Delegate.CreateDelegate(typeof(RouteCallback), addon, method) as RouteCallback;
                    // Delegate from Static method
                    //RouteCallback callback = method.CreateDelegate(typeof(RouteCallback)) as RouteCallback;
                    //RouteCallback callback = Delegate.CreateDelegate(typeof(RouteCallback), method) as RouteCallback;
                    Routes.Add(url, callback);


                    Console.WriteLine(string.Format("--> Registering route for '{0}'", url));
                }
            }
        }
Exemple #2
0
 public static void SetRunningAddon(KodiAddon addonInstance)
 {
     if (addonInstance == null)
     {
         // Addon finished running, allow another addon to start
         addonFinished.Set();
     }
     else
     {
         // Wait for the previous addon to finish
         Console.WriteLine("!!! Waiting for previous addon to finish");
         addonFinished.WaitOne();
         Console.WriteLine("!!! Previous addon finished, starting up");
     }
     runningAddon.SetTarget(addonInstance);
 }
Exemple #3
0
 public RouteManager(KodiAddon addon)
 {
     RegisterRoutes(addon);
 }
Exemple #4
0
 public static void SetRunningAddon(string addonUrl, KodiAddon addonInstance)
 {
     runningAddon.SetTarget(addonInstance);
 }
Exemple #5
0
 public static void RegisterPersistentAddon(string addonUrl, KodiAddon instance)
 {
     addonRefs.Add(addonUrl, instance);
 }
Exemple #6
0
 public static void RegisterPersistentAddon(string addonUrl, KodiAddon instance)
 {
     addonRefs[addonUrl] = instance;
 }