Rework architecture

This commit is contained in:
Alexey Golub
2020-04-21 21:30:42 +03:00
parent 130c0b6fe2
commit 8685a3d7e3
119 changed files with 1520 additions and 1560 deletions

View File

@@ -0,0 +1,27 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal class EmojiNode : MarkdownNode
{
public string? Id { get; }
public string Name { get; }
public bool IsAnimated { get; }
public bool IsCustomEmoji => !string.IsNullOrWhiteSpace(Id);
public EmojiNode(string? id, string name, bool isAnimated)
{
Id = id;
Name = name;
IsAnimated = isAnimated;
}
public EmojiNode(string name)
: this(null, name, false)
{
}
public override string ToString() => $"<Emoji> {Name}";
}
}

View File

@@ -0,0 +1,29 @@
using System.Collections.Generic;
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal enum TextFormatting
{
Bold,
Italic,
Underline,
Strikethrough,
Spoiler,
Quote
}
internal class FormattedNode : MarkdownNode
{
public TextFormatting Formatting { get; }
public IReadOnlyList<MarkdownNode> Children { get; }
public FormattedNode(TextFormatting formatting, IReadOnlyList<MarkdownNode> children)
{
Formatting = formatting;
Children = children;
}
public override string ToString() => $"<{Formatting}> (+{Children.Count})";
}
}

View File

@@ -0,0 +1,14 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal class InlineCodeBlockNode : MarkdownNode
{
public string Code { get; }
public InlineCodeBlockNode(string code)
{
Code = code;
}
public override string ToString() => $"<Code> {Code}";
}
}

View File

@@ -0,0 +1,22 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal class LinkNode : MarkdownNode
{
public string Url { get; }
public string Title { get; }
public LinkNode(string url, string title)
{
Url = url;
Title = title;
}
public LinkNode(string url)
: this(url, url)
{
}
public override string ToString() => $"<Link> {Title}";
}
}

View File

@@ -0,0 +1,6 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal abstract class MarkdownNode
{
}
}

View File

@@ -0,0 +1,25 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal enum MentionType
{
Meta,
User,
Channel,
Role
}
internal class MentionNode : MarkdownNode
{
public string Id { get; }
public MentionType Type { get; }
public MentionNode(string id, MentionType type)
{
Id = id;
Type = type;
}
public override string ToString() => $"<{Type} mention> {Id}";
}
}

View File

@@ -0,0 +1,17 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal class MultiLineCodeBlockNode : MarkdownNode
{
public string Language { get; }
public string Code { get; }
public MultiLineCodeBlockNode(string language, string code)
{
Language = language;
Code = code;
}
public override string ToString() => $"<{Language}> {Code}";
}
}

View File

@@ -0,0 +1,14 @@
namespace DiscordChatExporter.Domain.Markdown.Ast
{
internal class TextNode : MarkdownNode
{
public string Text { get; }
public TextNode(string text)
{
Text = text;
}
public override string ToString() => Text;
}
}