/// <summary> /// Attempts to extract the "current" view for the given gadget. /// </summary> /// <param name="context"></param> /// <param name="spec"></param> /// <returns></returns> private View GetView(GadgetContext context, GadgetSpec spec) { String viewName = context.getView(); View view = spec.getView(viewName); if (view == null) { JsonObject views = containerConfig.GetJsonObject(context.getContainer(), "gadgets.features/views"); foreach (DictionaryEntry v in views) { JsonArray aliases = ((JsonObject)v.Value)["aliases"] as JsonArray; if (aliases != null && view == null) { for (int i = 0, j = aliases.Length; i < j; ++i) { if (viewName == aliases.GetString(i)) { view = spec.getView(v.Key.ToString()); if (view != null) { break; } } } } } } if (view == null) { view = spec.getView(GadgetSpec.DEFAULT_VIEW); } return(view); }
public override List<preloadProcessor> createPreloadTasks(GadgetContext context, GadgetSpec gadget, PreloaderService.PreloadPhase phase) { List<preloadProcessor> preloads = new List<preloadProcessor>(); if (phase == PreloaderService.PreloadPhase.HTML_RENDER) { foreach(Preload preload in gadget.getModulePrefs().getPreloads()) { HashSet<String> preloadViews = preload.getViews(); if (preloadViews.Count == 0 || preloadViews.Contains(context.getView())) { PreloadTask task = new PreloadTask(context, preload, preload.getHref().ToString()); preloads.Add(new preloadProcessor(task.call)); } } } return preloads; }
public override List <preloadProcessor> createPreloadTasks(GadgetContext context, GadgetSpec gadget, PreloaderService.PreloadPhase phase) { List <preloadProcessor> preloads = new List <preloadProcessor>(); if (phase == PreloaderService.PreloadPhase.HTML_RENDER) { foreach (Preload preload in gadget.getModulePrefs().getPreloads()) { HashSet <String> preloadViews = preload.getViews(); if (preloadViews.Count == 0 || preloadViews.Contains(context.getView())) { PreloadTask task = new PreloadTask(context, preload, preload.getHref().ToString()); preloads.Add(new preloadProcessor(task.call)); } } } return(preloads); }
/// <summary> /// Attempts to extract the "current" view for the given gadget. /// </summary> /// <param name="context"></param> /// <param name="spec"></param> /// <returns></returns> private View GetView(GadgetContext context, GadgetSpec spec) { String viewName = context.getView(); View view = spec.getView(viewName); if (view == null) { JsonObject views = containerConfig.GetJsonObject(context.getContainer(), "gadgets.features/views"); foreach (DictionaryEntry v in views) { JsonArray aliases = ((JsonObject)v.Value)["aliases"] as JsonArray; if (aliases != null && view == null) { for (int i = 0, j = aliases.Length; i < j; ++i) { if (viewName == aliases.GetString(i)) { view = spec.getView(v.Key.ToString()); if (view != null) { break; } } } } } } if (view == null) { view = spec.getView(GadgetSpec.DEFAULT_VIEW); } return view; }