private string RenderContent(string file, string contents) { string html; try { var contentsWithoutHeader = contents.ExcludeHeader(); html = Path.GetExtension(file).IsMarkdownFile() ? LightweightMarkupEngine.Convert(contentsWithoutHeader).Trim() : contentsWithoutHeader; if (ContentTransformers != null) { html = ContentTransformers.Aggregate(html, (current, contentTransformer) => contentTransformer.Transform(current)); } } catch (Exception e) { Tracing.Info("Error ({0}) converting {1}", e.Message, file); Tracing.Debug(e.ToString()); html = String.Format("<p><b>Error converting markdown:</b><br />{0}</p><p>Original content:<br /><pre>{1}</pre></p>", e.Message, contents); } return(html); }
public ItemDefinition Clone() { var id = new ItemDefinition(ItemType); id.AllowedChildFilters = AllowedChildFilters.ToList(); id.AllowedIn = AllowedIn; id.AllowedParentFilters = AllowedParentFilters.ToList(); id.Attributes = Attributes.ToList(); id.AllowedZoneNames = AllowedZoneNames.ToList(); id.AuthorizedRoles = AuthorizedRoles != null?AuthorizedRoles.ToArray() : AuthorizedRoles; id.AvailableZones = AvailableZones.ToList(); id.Containers = new ContentList <IEditableContainer>(Containers.Select(ec => ec.TryClone())); id.ContentTransformers = ContentTransformers.ToList(); id.Description = Description; id.Discriminator = Discriminator; id.Displayables = new ContentList <IDisplayable>(Displayables.Select(d => d.TryClone())); id.Editables = new ContentList <IEditable>(Editables.Select(e => e.TryClone())); id.Enabled = Enabled; id.EditableModifiers = EditableModifiers.ToList(); id.IconUrl = IconUrl; id.Installer = Installer; id.IsDefined = IsDefined; id.NumberOfItems = 0; id.Metadata = Metadata.ToDictionary(kvp => kvp.Key, kvp => kvp.Value); id.AdditionalFlags = AdditionalFlags.ToList(); id.RemovedFlags = RemovedFlags.ToList(); id.Properties = Properties.ToDictionary(p => p.Key, p => p.Value.Clone()); id.RelatedTo = RelatedTo; id.SortOrder = SortOrder; id.TemplateKey = TemplateKey; id.Title = Title; id.ToolTip = ToolTip; return(id); }
public ItemDefinition Clone() { var id = new ItemDefinition(ItemType); id.AllowedChildFilters = AllowedChildFilters.ToList(); id.AllowedIn = AllowedIn; id.AllowedParentFilters = AllowedParentFilters.ToList(); id.AllowedZoneNames = AllowedZoneNames.ToList(); id.AuthorizedRoles = AuthorizedRoles != null?AuthorizedRoles.ToArray() : AuthorizedRoles; id.AvailableZones = AvailableZones.ToList(); id.Containers = Containers.ToList(); id.Description = Description; id.Discriminator = Discriminator; id.Displayables = new ContentList <IDisplayable>(Displayables); id.Editables = Editables.ToList(); id.Enabled = Enabled; id.IconUrl = IconUrl; id.Installer = Installer; id.IsDefined = IsDefined; id.EditableModifiers = EditableModifiers.ToList(); id.ContentTransformers = ContentTransformers.ToList(); id.NumberOfItems = 0; id.RelatedTo = RelatedTo; id.SortOrder = SortOrder; id.TemplateKey = TemplateKey; id.Title = Title; id.ToolTip = ToolTip; return(id); }
/// <summary>Adds an enumeration of containable editor or container to existing editors and to a container.</summary> /// <param name="containables">The editables to add.</param> public void AddRange(IEnumerable <IUniquelyNamed> containables) { foreach (var containable in containables) { if (containable is IEditable) { Editables.AddOrReplace(containable as IEditable); } if (containable is IEditableContainer) { Containers.AddOrReplace(containable as IEditableContainer); } if (containable is EditorModifierAttribute) { EditableModifiers.Add(containable as EditorModifierAttribute); } if (containable is IDisplayable) { Displayables.AddOrReplace(containable as IDisplayable); } if (containable is IContentTransformer) { ContentTransformers.Add(containable as IContentTransformer); } NamedOperators.Add(containable); } }
private void AddRangeInternal(IEnumerable <IUniquelyNamed> containables) { var list = new List <IUniquelyNamed>(containables); list.Sort((f, s) => { if (f is IComparable <IUniquelyNamed> ) { return((f as IComparable <IUniquelyNamed>).CompareTo(s)); } if (s is IComparable <IUniquelyNamed> ) { return(-(s as IComparable <IUniquelyNamed>).CompareTo(f)); } return(0); }); foreach (var containable in list) { if (containable is IEditable) { Editables.AddOrReplace(containable as IEditable); } if (containable is IEditableContainer) { Containers.AddOrReplace(containable as IEditableContainer); } if (containable is EditorModifierAttribute) { EditableModifiers.Add(containable as EditorModifierAttribute); } if (containable is IDisplayable) { Displayables.AddOrReplace(containable as IDisplayable); } if (containable is IContentTransformer) { ContentTransformers.Add(containable as IContentTransformer); } NamedOperators.Add(containable); } }
public void RemoveRange(IEnumerable <IUniquelyNamed> containables) { foreach (var containable in containables) { if (containable is IEditable) { Editables.Remove(containable as IEditable); } if (containable is IEditableContainer) { Containers.Remove(containable as IEditableContainer); } if (containable is IDisplayable) { Displayables.Remove(containable as IDisplayable); } if (containable is IContentTransformer) { ContentTransformers.Remove(containable as IContentTransformer); } } }