public Page() { foreach (Type t in from t in Assembly.GetExecutingAssembly().GetTypes() where !t.IsAbstract && t.IsClass && t.GetInterfaces().Contains(typeof(IDynamicTemplate)) select t) { IDynamicTemplate item = (IDynamicTemplate)t.GetConstructor(new Type[] { }).Invoke(null); item.CurrentPage = this; templates.Add(item.Name, item); } }
protected string ApplyNav() { IDynamicTemplate t = templates["nav"]; string nav = ""; foreach (Page p in PageHandler.Pages) { if (p.PageName != "") { } nav += t.ApplyTemplate(p, p.PageName); } return(nav); }
public DynamicTemplateContainer Deserialize(ref JsonReader reader, IJsonFormatterResolver formatterResolver) { var dynamicTemplateContainer = new DynamicTemplateContainer(); var count = 0; var formatter = formatterResolver.GetFormatter <DynamicTemplate>(); while (reader.ReadIsInArray(ref count)) { var objectCount = 0; string name = null; IDynamicTemplate template = null; while (reader.ReadIsInObject(ref objectCount)) { name = reader.ReadPropertyName(); template = formatter.Deserialize(ref reader, formatterResolver); } dynamicTemplateContainer.Add(name, template); } return(dynamicTemplateContainer); }