-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Removed experimental namespace
- Loading branch information
Showing
7 changed files
with
124 additions
and
1 deletion.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:String x:Key="/Default/Environment/UnitTesting/UnitTestSessionStore/Sessions/=142944d0_002Ded1d_002D4058_002D9ccf_002Dba061051a5fb/@EntryIndexedValue"><SessionState ContinuousTestingMode="0" IsActive="True" Name="All tests from Solution" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session">
 | ||
<Solution />
 | ||
</SessionState></s:String></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace D2.Writers | ||
{ | ||
public class D2Writer | ||
{ | ||
private readonly StringBuilder _sb = new StringBuilder(); | ||
|
||
public override string ToString() => _sb.ToString(); | ||
|
||
private void NewLine() => _sb.AppendLine(); | ||
private void Tab() => _sb.Append('\t'); | ||
private void Tab(int count) => _sb.Append('\t', count); | ||
|
||
private const string LABEL_SEPARATOR = ": "; | ||
private const string TAB_CHAR = " "; | ||
private StringBuilder AppendShape(string key) => _sb.AppendLine(key); | ||
private StringBuilder AppendShape(string key, string label) => _sb.AppendLine(key + LABEL_SEPARATOR + label); | ||
|
||
// Basic Elements | ||
public void DeclareShape(string key) => AppendShape(key); | ||
public void DeclareShape(string key, string label) => AppendShape(key, label); | ||
|
||
// Connections | ||
private const string CONNECTION = " -- "; | ||
private const string CONNECTION_BIDIRECTIONAL = " <-> "; | ||
private const string CONNECTION_FROM = " <- "; | ||
private const string CONNECTION_TO = " -> "; | ||
|
||
private static string BuildConnection(string connection, IEnumerable<string> keys) => string.Join(connection, keys); | ||
private void AppendConnection(IEnumerable<string> keys, string connection, string? label, Dictionary<string, string>? attributes) | ||
{ | ||
if (string.IsNullOrWhiteSpace(label)) | ||
_sb.AppendLine(BuildConnection(connection, keys)); | ||
else | ||
AppendShape(BuildConnection(connection, keys), label); | ||
|
||
if (attributes != null && attributes.Count > 0) | ||
{ | ||
WriteContainer(attributes); | ||
} | ||
} | ||
|
||
public void DeclareConnection(IEnumerable<string> keys) => AppendConnection(keys, CONNECTION, null, null); | ||
public void DeclareConnection(string label, IEnumerable<string> keys) => AppendConnection(keys, CONNECTION, label, null); | ||
public void DeclareConnection(string label, IEnumerable<string> keys, Dictionary<string, string> attributes) => AppendConnection(keys, CONNECTION, label, attributes); | ||
|
||
public void DeclareToConnection(IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_TO, null, null); | ||
public void DeclareToConnection(string label, IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_TO, label, null); | ||
public void DeclareToConnection(string label, IEnumerable<string> keys, Dictionary<string, string> attributes) => AppendConnection(keys, CONNECTION_TO, label, attributes); | ||
|
||
public void DeclareFromConnection(IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_FROM, null, null); | ||
public void DeclareFromConnection(string label, IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_FROM, label, null); | ||
public void DeclareFromConnection(string label, IEnumerable<string> keys, Dictionary<string, string> attributes) => AppendConnection(keys, CONNECTION_FROM, label, attributes); | ||
|
||
public void DeclareBidirectionalConnection(IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_BIDIRECTIONAL, null, null); | ||
public void DeclareBidirectionalConnection(string label, IEnumerable<string> keys) => AppendConnection(keys, CONNECTION_BIDIRECTIONAL, label, null); | ||
public void DeclareBidirectionalConnection(string label, IEnumerable<string> keys, Dictionary<string, string> attributes) => AppendConnection(keys, CONNECTION_BIDIRECTIONAL, label, attributes); | ||
|
||
// Containers | ||
private const string OPEN_CONTAINER = "{"; | ||
private const string CLOSE_CONTAINER = "}"; | ||
|
||
private void WriteContainer(Dictionary<string, string> attributes) | ||
{ | ||
_sb.AppendLine(OPEN_CONTAINER); | ||
foreach (var (key, value) in attributes) | ||
{ | ||
_sb.AppendLine(TAB_CHAR + key + LABEL_SEPARATOR + value); | ||
} | ||
_sb.AppendLine(CLOSE_CONTAINER); | ||
} | ||
|
||
private void WriteContainerInline(string prefix, Dictionary<string, string> attributes) | ||
{ | ||
foreach (var (key, value) in attributes) | ||
{ | ||
_sb.AppendLine(prefix + "." + key + LABEL_SEPARATOR + value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters