/// <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)); } } }
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); }
public RouteManager(KodiAddon addon) { RegisterRoutes(addon); }
public static void SetRunningAddon(string addonUrl, KodiAddon addonInstance) { runningAddon.SetTarget(addonInstance); }
public static void RegisterPersistentAddon(string addonUrl, KodiAddon instance) { addonRefs.Add(addonUrl, instance); }
public static void RegisterPersistentAddon(string addonUrl, KodiAddon instance) { addonRefs[addonUrl] = instance; }