13 private readonly
string url;
14 private readonly
string title;
15 private string extension;
16 private string contentType;
17 private readonly
int? width;
18 private readonly
int? height;
45 public string Url => this.url;
50 public string Title => this.title;
55 public int?
Width => this.width;
69 if (this.extension is
null)
71 int i = this.url.IndexOfAny(questionOrHash);
74 this.extension = Path.GetExtension(this.url.Substring(0, i));
76 if (
string.IsNullOrEmpty(this.extension))
78 int j = this.url.IndexOf(
'?', i + 1);
80 this.extension = Path.GetExtension(this.url.Substring(0, j));
82 this.extension = Path.GetExtension(this.url);
86 this.extension = Path.GetExtension(this.url);
89 return this.extension;
93 private static readonly
char[] questionOrHash =
new char[] {
'?',
'#' };
102 if (this.contentType is
null)
105 return this.contentType;
115 Output.WriteStartElement(
"MultimediaItem");
116 Output.WriteAttributeString(
"url", this.url);
117 Output.WriteAttributeString(
"title", this.title);
118 Output.WriteAttributeString(
"extension", this.extension);
119 Output.WriteAttributeString(
"contentType", this.contentType);
121 if (this.width.HasValue)
122 Output.WriteAttributeString(
"width", this.width.Value.ToString());
124 if (this.height.HasValue)
125 Output.WriteAttributeString(
"height", this.height.Value.ToString());
127 Output.WriteEndElement();
138 this.url == Obj.url &&
139 this.title == Obj.title &&
140 this.extension == Obj.extension &&
141 this.contentType == Obj.contentType &&
142 this.width == Obj.width &&
143 this.height == Obj.height;
152 int h1 = this.url?.GetHashCode() ?? 0;
153 int h2 = this.title?.GetHashCode() ?? 0;
155 h1 = ((h1 << 5) + h1) ^ h2;
157 h2 = this.extension?.GetHashCode() ?? 0;
158 h1 = ((h1 << 5) + h1) ^ h2;
160 h2 = this.contentType?.GetHashCode() ?? 0;
161 h1 = ((h1 << 5) + h1) ^ h2;
163 h2 = this.width?.GetHashCode() ?? 0;
164 h1 = ((h1 << 5) + h1) ^ h2;
166 h2 = this.height?.GetHashCode() ?? 0;
167 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.