2using System.Reflection;
3using System.Collections.Generic;
4using System.Threading.Tasks;
16 private static readonly Dictionary<Type, IMultimediaRenderer[]> renderersPerType =
new Dictionary<Type, IMultimediaRenderer[]>();
19 private Type handlerType =
null;
21 private readonly
bool aloneInParagraph;
59 if (this.handlerType is
null || this.handlerType != typeof(T))
62 this.handlerType = typeof(T);
65 return (T)this.handler;
76 int i, c = URLs.Length;
79 for (i = 0; i < c; i++)
102 CurrentGrade = Handler.
Supports(Item);
103 if (CurrentGrade > BestGrade && Handler is T TypedHandler)
106 BestGrade = CurrentGrade;
124 lock (renderersPerType)
128 List<IMultimediaRenderer> Handlers =
new List<IMultimediaRenderer>();
147 Handlers.Add(Handler);
150 Renderers = Handlers.ToArray();
151 renderersPerType[typeof(T)] = Renderers;
160 Types.OnInvalidated += Types_OnInvalidated;
163 private static void Types_OnInvalidated(
object Sender, EventArgs e)
165 lock (renderersPerType)
167 renderersPerType.Clear();
202 x.aloneInParagraph == this.aloneInParagraph &&
204 base.SameMetaData(E);
215 this.aloneInParagraph == x.aloneInParagraph &&
226 int h1 = base.GetHashCode();
227 int h2 = this.aloneInParagraph.GetHashCode();
229 h1 = ((h1 << 5) + h1) ^ h2;
232 h1 = ((h1 << 5) + h1) ^ h2;
248 if (!(
Items is
null))
252 if (
Items.Length > 1)
257 if (Statistics.IntMultimediaPerContentType is
null)
259 Statistics.IntMultimediaPerContentType =
new Dictionary<string, List<string>>();
260 Statistics.IntMultimediaPerContentCategory =
new Dictionary<string, List<string>>();
261 Statistics.IntMultimediaPerExtension =
new Dictionary<string, List<string>>();
264 IncItem(Item.
ContentType, Item.
Url, Statistics.IntMultimediaPerContentType);
265 IncItem(Item.
Extension, Item.
Url, Statistics.IntMultimediaPerExtension);
268 int i = s.IndexOf(
'/');
270 s = s.Substring(0, i);
272 IncItem(s, Item.
Url, Statistics.IntMultimediaPerContentCategory);
277 private static void IncItem(
string Key,
string Url, Dictionary<
string, List<string>> Dictionary)
279 if (!Dictionary.TryGetValue(Key, out List<string> List))
281 List =
new List<string>();
282 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 IEnumerable< 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.
bool AloneInParagraph
If the element is alone in a paragraph.
Multimedia(MarkdownDocument Document, IEnumerable< MarkdownElement > ChildElements, bool AloneInParagraph, params MultimediaItem[] Items)
Multimedia
static IMultimediaRenderer[] GetRenderers< T >()
Multimedia handlers.
override MarkdownElementChildren Create(IEnumerable< MarkdownElement > Children, MarkdownDocument Document)
Creates an object of the same type, and meta-data, as the current object, but with content defined by...
override Task Render(IRenderer Output)
Renders the element.
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.
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.