Skip to content

Commit

Permalink
First impl of MultiDict
Browse files Browse the repository at this point in the history
  • Loading branch information
ObiWanLansi committed Dec 7, 2023
1 parent f89d2a1 commit 105188a
Show file tree
Hide file tree
Showing 152 changed files with 10,664 additions and 10,729 deletions.
477 changes: 238 additions & 239 deletions DoofesZeug.Generators/Src/Documentation/GenerateEntityOverview.cs

Large diffs are not rendered by default.

207 changes: 103 additions & 104 deletions DoofesZeug.Generators/Src/Documentation/GenerateEnumerationsOverview.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,170 +14,169 @@



namespace DoofesZeug.Documentation
namespace DoofesZeug.Documentation;

public static class GenerateEnumerationsOverview
{
public static class GenerateEnumerationsOverview
{
private static readonly string OUTPUTDIRECTORY = @"O:\DoofesZeug\Documentation\Generated\Enumerations";
private static readonly string OUTPUTDIRECTORY = @"O:\DoofesZeug\Documentation\Generated\Enumerations";

private static readonly Type ENTITY_BASE = typeof(Entity);
private static readonly Type ENTITY_BASE = typeof(Entity);

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


private static void AppendEnum( Type type, StringBuilder sbPUML )
private static void AppendEnum( Type type, StringBuilder sbPUML )
{
sbPUML.AppendLine();
sbPUML.AppendLine($"enum {type.Name} {{");

foreach( object value in Enum.GetValues(type) )
{
sbPUML.AppendLine();
sbPUML.AppendLine($"enum {type.Name} {{");
sbPUML.AppendLine($" {value}");
}

foreach( object value in Enum.GetValues(type) )
{
sbPUML.AppendLine($" {value}");
}
sbPUML.AppendLine("}");
sbPUML.AppendLine();
}

sbPUML.AppendLine("}");
sbPUML.AppendLine();
}

private static void GenerateUmlDiagramm( Type type, StringBuilder sb )
{
string strOutputDirectory = $"{OUTPUTDIRECTORY}\\{type.Namespace}";
string strDiagrammFilenamePng = $"{type.Name}.png";
string strDiagrammFilenamePuml = $"{type.Name}.puml";

private static void GenerateUmlDiagramm( Type type, StringBuilder sb )
{
string strOutputDirectory = $"{OUTPUTDIRECTORY}\\{type.Namespace}";
string strDiagrammFilenamePng = $"{type.Name}.png";
string strDiagrammFilenamePuml = $"{type.Name}.puml";
//---------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------
sb.AppendLine();
sb.AppendLine($"![{strDiagrammFilenamePng}](./{strDiagrammFilenamePng} \"{type.Name}\")");

sb.AppendLine();
sb.AppendLine($"![{strDiagrammFilenamePng}](./{strDiagrammFilenamePng} \"{type.Name}\")");
//---------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------
StringBuilder sbPUML = new(8192);

StringBuilder sbPUML = new(8192);
sbPUML.AppendLine("@startuml");
sbPUML.AppendLine("hide empty members");
sbPUML.AppendLine("skinparam monochrome true");
sbPUML.AppendLine("skinparam backgroundcolor transparent");

sbPUML.AppendLine("@startuml");
sbPUML.AppendLine("hide empty members");
sbPUML.AppendLine("skinparam monochrome true");
sbPUML.AppendLine("skinparam backgroundcolor transparent");
//---------------------------------------------

//---------------------------------------------
AppendEnum(type, sbPUML);

AppendEnum(type, sbPUML);
//---------------------------------------------

//---------------------------------------------
sbPUML.AppendLine("@enduml");

sbPUML.AppendLine("@enduml");
//---------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------
string strOutputFilename = $"{strOutputDirectory}\\{strDiagrammFilenamePuml}";
File.WriteAllTextAsync(strOutputFilename, sbPUML.ToString(), Encoding.UTF8);
GeneratorTool.PlantUml(strOutputFilename);
}

string strOutputFilename = $"{strOutputDirectory}\\{strDiagrammFilenamePuml}";
File.WriteAllTextAsync(strOutputFilename, sbPUML.ToString(), Encoding.UTF8);
GeneratorTool.PlantUml(strOutputFilename);
}
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------

private static void GenerateEnumerationFile( Type type )
{
string strOutputDirectory = $"{OUTPUTDIRECTORY}\\{type.Namespace}";

private static void GenerateEnumerationFile( Type type )
if( Directory.Exists(strOutputDirectory) == false )
{
string strOutputDirectory = $"{OUTPUTDIRECTORY}\\{type.Namespace}";
Directory.CreateDirectory(strOutputDirectory);
}

if( Directory.Exists(strOutputDirectory) == false )
{
Directory.CreateDirectory(strOutputDirectory);
}
//---------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------
Out.WriteLineAsync($"Create markdown for: {type.FullName}");

Out.WriteLineAsync($"Create markdown for: {type.FullName}");
StringBuilder sb = new(8192);

StringBuilder sb = new(8192);
sb.AppendLine($"# {type.Name}");
sb.AppendLine();

sb.AppendLine($"# {type.Name}");
sb.AppendLine();
sb.AppendLine($"## Diagram");
GenerateUmlDiagramm(type, sb);

sb.AppendLine($"## Diagram");
GenerateUmlDiagramm(type, sb);
//---------------------------------------------------------------------------------------------------------

//---------------------------------------------------------------------------------------------------------
sb.AppendLine();
sb.AppendLine("<hr style=\"background: blue;\" />");

sb.AppendLine();
sb.AppendLine("<hr style=\"background: blue;\" />");
File.WriteAllTextAsync($"{strOutputDirectory}\\{type.Name}.md", sb.ToString(), Encoding.UTF8);
}

File.WriteAllTextAsync($"{strOutputDirectory}\\{type.Name}.md", sb.ToString(), Encoding.UTF8);
}

private static void GenerateEnumerationOverviewFile( List<Type> enumerations )
{
StringBuilder sb = new(8192);
sb.AppendLine("# Enumerations Overview");

private static void GenerateEnumerationOverviewFile( List<Type> enumerations )
foreach( IGrouping<string, Type> enumerationgroup in from enumeration in enumerations group enumeration by enumeration.Namespace into ng orderby ng.Key select ng )
{
StringBuilder sb = new(8192);
sb.AppendLine("# Enumerations Overview");
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine($"## `{enumerationgroup.Key}`");
sb.AppendLine("");

foreach( IGrouping<string, Type> enumerationgroup in from enumeration in enumerations group enumeration by enumeration.Namespace into ng orderby ng.Key select ng )
{
sb.AppendLine("");
sb.AppendLine("");
sb.AppendLine($"## `{enumerationgroup.Key}`");
sb.AppendLine("");
sb.AppendLine("|Enumeration|Description|Values|");
sb.AppendLine("|:----------|:----------|:-----|");

sb.AppendLine("|Enumeration|Description|Values|");
sb.AppendLine("|:----------|:----------|:-----|");
string strPath = enumerationgroup.Key [11..].Replace('.', '/');

string strPath = enumerationgroup.Key [11..].Replace('.', '/');
foreach( Type enumeration in from type in enumerationgroup orderby type.Name select type )
{
DescriptionAttribute da = (DescriptionAttribute) enumeration.GetCustomAttribute(typeof(DescriptionAttribute));

foreach( Type enumeration in from type in enumerationgroup orderby type.Name select type )
if( da == null )
{
DescriptionAttribute da = (DescriptionAttribute) enumeration.GetCustomAttribute(typeof(DescriptionAttribute));

if( da == null )
{
throw new Exception($"{enumeration.FullName} have no description!");
}
throw new Exception($"{enumeration.FullName} have no description!");
}

da.Validate(enumeration);
da.Validate(enumeration);

string strLinkToMarkdown = $"[{enumeration.Name}](./{enumerationgroup.Key}/{enumeration.Name}.md)";
string strLinkToMarkdown = $"[{enumeration.Name}](./{enumerationgroup.Key}/{enumeration.Name}.md)";

sb.AppendLine($"|{strLinkToMarkdown}|{da.Description}|{Enum.GetNames(enumeration).ToFlatString()}|");
}
sb.AppendLine($"|{strLinkToMarkdown}|{da.Description}|{Enum.GetNames(enumeration).ToFlatString()}|");
}
}

sb.AppendLine();
sb.AppendLine("<hr style=\"background: blue;\" />");
sb.AppendLine();
sb.AppendLine("<hr style=\"background: blue;\" />");

File.WriteAllTextAsync($"{OUTPUTDIRECTORY}\\README.md", sb.ToString(), Encoding.UTF8);
}
File.WriteAllTextAsync($"{OUTPUTDIRECTORY}\\README.md", sb.ToString(), Encoding.UTF8);
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------------------------------------------------------------------------


public static void Generate()
{
Assembly assembly = ENTITY_BASE.Assembly;
public static void Generate()
{
Assembly assembly = ENTITY_BASE.Assembly;

Out.WriteLineAsync();
Out.WriteLineAsync($"{assembly.FullName}");
Out.WriteLineAsync();
Out.WriteLineAsync($"{assembly.FullName}");

new DirectoryInfo(OUTPUTDIRECTORY).DeleteDirectoryContentRecursiv(ex => Error.WriteLineAsync(ex.Message));
new DirectoryInfo(OUTPUTDIRECTORY).DeleteDirectoryContentRecursiv(ex => Error.WriteLineAsync(ex.Message));

//---------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------

List<Type> enumerations = new();
List<Type> enumerations = new();

foreach( Type type in assembly.ExportedTypes )
foreach( Type type in assembly.ExportedTypes )
{
if( type.IsEnum == false )
{
if( type.IsEnum == false )
{
continue;
}
enumerations.Add(type);
continue;
}
enumerations.Add(type);
}

//---------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------------------

enumerations.ForEach(enumeration => GenerateEnumerationFile(enumeration));
enumerations.ForEach(enumeration => GenerateEnumerationFile(enumeration));

GenerateEnumerationOverviewFile(enumerations);
}
GenerateEnumerationOverviewFile(enumerations);
}
}
81 changes: 40 additions & 41 deletions DoofesZeug.Generators/Src/Examples/Entities/PersonExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,49 @@



namespace DoofesZeug.Examples.Entities
namespace DoofesZeug.Examples.Entities;

public static class PersonExample
{
public static class PersonExample
public static void CreatePerson()
{
public static void CreatePerson()
Person p = new Person
{
Person p = new Person
FirstName = "John",
LastName = "Doe",
Gender = Gender.Male,

DateOfBirth = (11, 02, 1942),
DateOfDeath = (22, 03, 1942 + 42),

Handedness = Handedness.Left,
BloodGroup = BloodGroup.AB,
HairColor = WellKnownHairColor.Blond,
Religion = MajorReligion.Buddhism,
Profession = WellKnownProfession.Engineer,
DriverLicense = EuropeanDriverLicense.B | EuropeanDriverLicense.AM,

AverageHeight = 174,
AverageWeight = 72,

Phone = new Phone
{
Number = "+49 54321 424269",
PhoneType = PhoneType.Landline,
InformationType = InformationType.Private
},
EMailAddress = new EMailAddress
{
FirstName = "John",
LastName = "Doe",
Gender = Gender.Male,

DateOfBirth = (11, 02, 1942),
DateOfDeath = (22, 03, 1942 + 42),

Handedness = Handedness.Left,
BloodGroup = BloodGroup.AB,
HairColor = WellKnownHairColor.Blond,
Religion = MajorReligion.Buddhism,
Profession = WellKnownProfession.Engineer,
DriverLicense = EuropeanDriverLicense.B | EuropeanDriverLicense.AM,

AverageHeight = 174,
AverageWeight = 72,

Phone = new Phone
{
Number = "+49 54321 424269",
PhoneType = PhoneType.Landline,
InformationType = InformationType.Private
},
EMailAddress = new EMailAddress
{
Address = "obiwanlansi@github.com",
InformationType = InformationType.Business
},
Homepage = new Homepage
{
Url = new("https://github.com/ObiWanLansi"),
InformationType = InformationType.Business
}
};

Console.Out.WriteLineAsync(p.ToStringTable());
}
Address = "obiwanlansi@github.com",
InformationType = InformationType.Business
},
Homepage = new Homepage
{
Url = new("https://github.com/ObiWanLansi"),
InformationType = InformationType.Business
}
};

Console.Out.WriteLineAsync(p.ToStringTable());
}
}
Loading

0 comments on commit 105188a

Please sign in to comment.