/// <summary> /// Gets the conventions for the specified view. /// </summary> /// <param name="view">The view.</param> /// <returns>The applicable conventions.</returns> public IEnumerable <IViewApplicable> GetConventionsFor(DependencyObject view) { IViewApplicable[] conventions; var viewType = view.GetType(); var useConventionCache = ShouldUseConventionCache(view); if (useConventionCache) { if (!viewConventions.TryGetValue(viewType, out conventions)) { conventions = conventionManager.DetermineConventions(this, view).ToArray(); viewConventions[viewType] = conventions; Log.Info("Cached conventions for {0}.", view); } else { Log.Info("Using convention cache for {0}.", view); } } else { conventions = conventionManager.DetermineConventions(this, view).ToArray(); Log.Info("Ignoring convention cache for {0}.", view); } return(conventions); }
/// <summary> /// Determines the conventions for the specified view and view model description. /// </summary> /// <param name="conventionManager">The convention manager.</param> /// <param name="viewModelDescription">The view model description.</param> /// <param name="view">The view.</param> /// <returns>The applicalble conventions.</returns> public static IEnumerable <IViewApplicable> DetermineConventions(this IConventionManager conventionManager, IViewModelDescription viewModelDescription, DependencyObject view) { return(conventionManager.DetermineConventions(viewModelDescription, SelectElementsToInspect(conventionManager, view))); }