14 private readonly
string url;
15 private readonly
string title;
16 private string extension;
17 private string contentType;
18 private readonly
int? width;
19 private readonly
int? height;
46 public string Url => this.url;
51 public string Title => this.title;
56 public int?
Width => this.width;
70 if (this.extension is
null)
72 int i = this.url.IndexOfAny(questionOrHash);
75 this.extension = Path.GetExtension(this.url.Substring(0, i));
77 if (
string.IsNullOrEmpty(this.extension))
79 int j = this.url.IndexOf(
'?', i + 1);
81 this.extension = Path.GetExtension(this.url.Substring(0, j));
83 this.extension = Path.GetExtension(this.url);
87 this.extension = Path.GetExtension(this.url);
90 return this.extension;
94 private static readonly
char[] questionOrHash =
new char[] {
'?',
'#' };
103 if (this.contentType is
null)
106 return this.contentType;
116 Output.WriteStartElement(
"MultimediaItem");
117 Output.WriteAttributeString(
"url", this.url);
118 Output.WriteAttributeString(
"title", this.title);
119 Output.WriteAttributeString(
"extension", this.extension);
120 Output.WriteAttributeString(
"contentType", this.contentType);
122 if (this.width.HasValue)
123 Output.WriteAttributeString(
"width", this.width.Value.ToString());
125 if (this.height.HasValue)
126 Output.WriteAttributeString(
"height", this.height.Value.ToString());
128 Output.WriteEndElement();
139 this.url == Obj.url &&
140 this.title == Obj.title &&
141 this.extension == Obj.extension &&
142 this.contentType == Obj.contentType &&
143 this.width == Obj.width &&
144 this.height == Obj.height;
153 int h1 = this.url?.GetHashCode() ?? 0;
154 int h2 = this.title?.GetHashCode() ?? 0;
156 h1 = ((h1 << 5) + h1) ^ h2;
158 h2 = this.extension?.GetHashCode() ?? 0;
159 h1 = ((h1 << 5) + h1) ^ h2;
161 h2 = this.contentType?.GetHashCode() ?? 0;
162 h1 = ((h1 << 5) + h1) ^ h2;
164 h2 = this.width?.GetHashCode() ?? 0;
165 h1 = ((h1 << 5) + h1) ^ h2;
167 h2 = this.height?.GetHashCode() ?? 0;
168 h1 = ((h1 << 5) + h1) ^ h2;
Static class managing encoding and decoding of internet content.
static string GetContentType(string FileExtension)
Gets the content type of an item, given its file extension. It uses the TryGetContentType to see if a...
Contains a markdown document. This markdown document class supports original markdown,...
string Extension
Resource extension.
override int GetHashCode()
Serves as the default hash function.
MultimediaItem(MarkdownDocument Doc, string Url, string Title, int? Width, int? Height)
Multimedia item.
MarkdownDocument Document
Markdown document
override bool Equals(object obj)
Determines whether the specified object is equal to the current object.
string ContentType
Content Type
int? Height
Height of media item, if available.
void Export(XmlWriter Output)
Exports the element to XML.
string Title
Optional title.
int? Width
Width of media item, if available.
Contains information about an emoji image.