2using System.Reflection;
4using System.Threading.Tasks;
17 private static readonly Dictionary<Type, IMultimediaRenderer[]> renderersPerType =
new Dictionary<Type, IMultimediaRenderer[]>();
20 private Type handlerType =
null;
22 private readonly
bool aloneInParagraph;
60 if (this.handlerType is
null || this.handlerType != typeof(T))
63 this.handlerType = typeof(T);
66 return (T)this.handler;
77 int i, c = URLs.Length;
80 for (i = 0; i < c; i++)
103 CurrentGrade = Handler.
Supports(Item);
104 if (CurrentGrade > BestGrade && Handler is T TypedHandler)
107 BestGrade = CurrentGrade;
125 lock (renderersPerType)
148 Handlers.Add(Handler);
151 Renderers = Handlers.ToArray();
152 renderersPerType[typeof(T)] = Renderers;
161 Types.OnInvalidated += Types_OnInvalidated;
164 private static void Types_OnInvalidated(
object Sender, EventArgs e)
166 lock (renderersPerType)
168 renderersPerType.Clear();
203 x.aloneInParagraph == this.aloneInParagraph &&
205 base.SameMetaData(E);
216 this.aloneInParagraph == x.aloneInParagraph &&
227 int h1 = base.GetHashCode();
228 int h2 = this.aloneInParagraph.GetHashCode();
230 h1 = ((h1 << 5) + h1) ^ h2;
233 h1 = ((h1 << 5) + h1) ^ h2;
249 if (!(
Items is
null))
253 if (
Items.Length > 1)
258 if (Statistics.IntMultimediaPerContentType is
null)
260 Statistics.IntMultimediaPerContentType =
new Dictionary<string, ChunkedList<string>>();
261 Statistics.IntMultimediaPerContentCategory =
new Dictionary<string, ChunkedList<string>>();
262 Statistics.IntMultimediaPerExtension =
new Dictionary<string, ChunkedList<string>>();
265 IncItem(Item.
ContentType, Item.
Url, Statistics.IntMultimediaPerContentType);
266 IncItem(Item.
Extension, Item.
Url, Statistics.IntMultimediaPerExtension);
269 int i = s.IndexOf(
'/');
271 s = s.Substring(0, i);
273 IncItem(s, Item.
Url, Statistics.IntMultimediaPerContentCategory);
278 private static void IncItem(
string Key,
string Url, Dictionary<
string,
ChunkedList<string>> Dictionary)
283 Dictionary[Key] = List;
Contains a markdown document. This markdown document class supports original markdown,...
Contains some basic statistical information about a Markdown document.
int NrMultimedia
Number of multimedia (total).
int NrMultiformatMultimedia
Number of multi-formatted multimedia.
Abstract base class for all markdown elements with a variable number of child elements.
override ChunkedList< MarkdownElement > Children
Any children of the element.
Abstract base class for all markdown elements.
MarkdownDocument Document
Markdown document.
static bool AreEqual(Array Items1, Array Items2)
Checks if two typed arrays are equal
string Extension
Resource extension.
string ContentType
Content Type
static IMultimediaContent GetMultimediaHandler< T >(params string[] URLs)
Gets the best multimedia handler for a set of URLs or file names.
MultimediaItem[] Items
Multimedia items.
override bool OutsideParagraph
If element, parsed as a span element, can stand outside of a paragraph if alone in it.
T MultimediaHandler< T >()
Multimedia handler.
override bool SameMetaData(MarkdownElement E)
If the current object has same meta-data as E (but not necessarily same content).
override bool InlineSpanElement
If the element is an inline span element.
Multimedia(MarkdownDocument Document, ChunkedList< MarkdownElement > ChildElements, bool AloneInParagraph, params MultimediaItem[] Items)
Multimedia
bool AloneInParagraph
If the element is alone in a paragraph.
static IMultimediaRenderer[] GetRenderers< T >()
Multimedia handlers.
override Task Render(IRenderer Output)
Renders the element.
override MarkdownElementChildren Create(ChunkedList< MarkdownElement > Children, MarkdownDocument Document)
Creates an object of the same type, and meta-data, as the current object, but with content defined by...
override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
override int GetHashCode()
Serves as the default hash function.
override void IncrementStatistics(MarkdownStatistics Statistics)
Increments the property or properties in Statistics corresponding to the element.
Static class managing the application event log. Applications and services log events on this static ...
static void Exception(Exception Exception, string Object, string Actor, string EventId, EventLevel Level, string Facility, string Module, params KeyValuePair< string, object >[] Tags)
Logs an exception. Event type will be determined by the severity of the exception.
A chunked list is a linked list of chunks of objects of type T .
Static class that dynamically manages types and interfaces available in the runtime environment.
static object[] NoParameters
Contains an empty array of parameter values.
static Type[] GetTypesImplementingInterface(string InterfaceFullName)
Gets all types implementing a given interface.
static ConstructorInfo GetDefaultConstructor(Type Type)
Gets the default constructor of a type, if one exists.
Interface for all markdown handlers of multimedia content.
Grade Supports(MultimediaItem Item)
Checks how well the handler supports multimedia content of a given type.
Interface for multimedia content renderers.
Interface for Markdown renderers.