private static IViewTemplate GetMasterOf(IViewTemplate t) { if (t == null) return null; PropertyInfo p = t.GetType().GetProperty("Master"); if (p == null || !typeof(IViewTemplate).IsAssignableFrom(p.PropertyType)) return null; return (IViewTemplate)p.GetValue(t, null); }
public virtual SparkViewDescriptor BuildDescriptor(IViewTemplate template, bool searchForMaster, IDictionary<string, object> extra, ICollection<string> searchedLocations) { var descriptor = new SparkViewDescriptor { TargetNamespace = GetNamespaceEncodedPathViewPath(template.GetFullPath()) }; descriptor.Templates.Add(template.GetFullPath().Replace("\\", "/")); if (searchForMaster && TrailingUseMasterName(descriptor) == null) { LocatePotentialTemplate( PotentialDefaultMasterLocations(template, extra), descriptor.Templates, null); } var trailingUseMaster = TrailingUseMasterName(descriptor); while (searchForMaster && !string.IsNullOrEmpty(trailingUseMaster)) { if (!LocatePotentialTemplate( PotentialMasterLocations(template, trailingUseMaster, extra), descriptor.Templates, searchedLocations)) { return null; } trailingUseMaster = TrailingUseMasterName(descriptor); } return descriptor; }
public IView FindView(IViewTemplate template) { IView view = GetPageInstance(template); if (view == null) return null; return view; }
public void Render(IViewTemplate template) { if (template.GetType() == typeof(CarViewTemplate)) { //Do some stuff } }
internal static void InitMasterRecursively(IView v, IViewTemplate t) { IViewTemplate m = GetMasterOf(t); while (m != null) { v = GetMasterInstance(m, v); m = GetMasterOf(m); } }
public void SetUp() { firstViewEngine = A.Fake<IViewEngine>(); secondViewEngine = A.Fake<IViewEngine>(); endpoint = A.Fake<IEndpoint>(); firstTemplate = A.Fake<IViewTemplate>(); secontTemplate = A.Fake<IViewTemplate>(); A.CallTo(() => firstViewEngine.FindAllTemplates()).Returns(Enumerable.Repeat(firstTemplate, 1)); A.CallTo(() => secondViewEngine.FindAllTemplates()).Returns(Enumerable.Repeat(secontTemplate, 1)); viewEngineCollection = new ViewEngineCollection(new List<IViewEngine> { firstViewEngine, secondViewEngine }); }
/// <summary>Reveals the specified content within the dialog box.</summary> /// <param name="dialog">The dialog box.</param> /// <param name="content">The content to show within the dialog.</param> /// <param name="width">The pixel width of the dialog.</param> /// <param name="height">The pixel height of the dialog.</param> /// <returns>The new dialog content.</returns> public static IDialogContent ContentDialog(this IAcceptCancelDialog dialog, IViewTemplate content, double width, double height) { // Setup initial conditions. if (dialog == null) throw new ArgumentNullException("dialog"); if (content == null) throw new ArgumentNullException("content"); // Create the content view. var dialogContent = new DialogContent { ParentDialog = dialog, Width = width, Height = height, Content = { Template = content.Template }, }; if (content.ViewModel != null) dialogContent.Content.ViewModel = content.ViewModel; AssignAsPresenter(dialog, dialogContent); // Finish up. return dialogContent; }
public abstract IView FindView(IViewTemplate view);
public UWebViewFile(IViewTemplate viewTemplate) { this.viewTemplate = viewTemplate; created = DateTime.Now.Ticks; }
protected virtual IEnumerable<string> PotentialMasterLocations(IViewTemplate template, string masterName, IDictionary<string, object> extra) { return ApplyFilters(new[] { string.Format("Layouts{0}{1}.spark", template.PathSeperator, masterName), string.Format("Shared{0}{1}.spark", template.PathSeperator, masterName) }, extra); }
protected static IView GetMasterInstance(IViewTemplate template, IView parent) { Type templateType = template.GetType(); if (_masterTypeCache == null) _masterTypeCache = new Dictionary<Type, string>(); string viewPath; if (!_masterTypeCache.TryGetValue(templateType, out viewPath)) { lock (_masterTypeCache) { viewPath = GetMasterType(templateType); _masterTypeCache.Add(templateType, viewPath); } } if (viewPath == null) return null; ViewMaster master; ViewPage parentPage = parent as ViewPage; if (parentPage != null) { parentPage.MasterPageFile = viewPath; master = parentPage.Master; } else { ViewMaster parentMaster = parent as ViewMaster; if (parentMaster != null) { parentMaster.MasterPageFile = viewPath; master = parentMaster.Master; } else throw new Exception("Expected ViewMaster or ViewPage"); } master.SetTemplate(template); return master; }
protected static IView GetControlInstance(IViewTemplate template) { Type templateType = template.GetType(); if (_controlTypeCache == null) _controlTypeCache = new Dictionary<Type, Type>(); Type viewType; if (!_controlTypeCache.TryGetValue(templateType, out viewType)) { lock (_controlTypeCache) { viewType = GetControlType(templateType); _controlTypeCache.Add(templateType, viewType); } } if (viewType == null) return null; else { object o = System.Activator.CreateInstance(viewType); ViewPage p = o as ViewPage; if (p != null) p.SetTemplate(template); else { ViewControl c = o as ViewControl; if (c != null) c.SetTemplate(template); } return (IView)o; } }
protected static IView GetPageInstance(IViewTemplate template) { Type templateType = template.GetType(); if (_pageTypeCache == null) _pageTypeCache = new Dictionary<Type, Type>(); Type viewType; if (!_pageTypeCache.TryGetValue(templateType, out viewType)) { lock (_pageTypeCache) { viewType = GetPageType(templateType); //_pageTypeCache.Add(templateType, viewType); } } if (viewType == null) return null; else { ViewPage p = (ViewPage)System.Activator.CreateInstance(viewType); p.SetTemplate(template); return p; } }
public IView FindView(IViewTemplate view) { return new MockView(view); }
public MockView(IViewTemplate template) { _template = template; }
public static IView CreateView(IViewTemplate view) { return new MockView(view); }