Skip to content

Commit

Permalink
Improved class diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayPianikov committed May 10, 2024
1 parent 8e9dba3 commit 811e374
Show file tree
Hide file tree
Showing 32 changed files with 71 additions and 62 deletions.
4 changes: 2 additions & 2 deletions readme/accumulators.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ classDiagram
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- Service : IService
ValueTupleᐸIServiceˏMyAccumulatorᐳ *-- MyAccumulator : MyAccumulator
Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.AbcDependency) IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency) IDependency
Service o-- "PerBlock" AbcDependency : IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.AccumulatorScenario.XyzDependency) IDependency
Service o-- "PerBlock" AbcDependency : IDependency
Composition ..> ValueTupleᐸIServiceˏMyAccumulatorᐳ : ValueTupleᐸIServiceˏMyAccumulatorᐳ Root
```

Expand Down
4 changes: 2 additions & 2 deletions readme/async-disposable-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ classDiagram
<<interface>>
}
Session *-- Composition : Composition
Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ
Service o-- "Scoped" Dependency : IDependency
Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ
Service o-- "Scoped" Dependency : IDependency
Composition ..> Service : IService SessionRoot
Composition ..> Program : Program ProgramRoot
FuncᐸSessionᐳ *-- Session : Session
Expand Down
2 changes: 1 addition & 1 deletion readme/async-disposable-singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
4 changes: 2 additions & 2 deletions readme/auto-scoped.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ classDiagram
class IDependency {
<<interface>>
}
Program o-- "PerResolve" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ
Service o-- "Scoped" Dependency : IDependency
Program o-- "PerResolve" FuncᐸIServiceᐳ : FuncᐸIServiceᐳ
Service o-- "Scoped" Dependency : IDependency
IService *-- Composition : Composition
Composition ..> Service : Service SessionRoot
Composition ..> Program : Program ProgramRoot
Expand Down
3 changes: 1 addition & 2 deletions readme/default-lifetime.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Service o-- "2 Singleton" Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
2 changes: 1 addition & 1 deletion readme/disposable-singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
4 changes: 2 additions & 2 deletions readme/enumerable-generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ classDiagram
}
Composition ..> ServiceᐸInt32ᐳ : IServiceᐸInt32ᐳ IntRoot
Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ StringRoot
ServiceᐸInt32ᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸInt32ᐳᐳ : IEnumerableᐸIDependencyᐸInt32ᐳᐳ
ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ
ServiceᐸInt32ᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸInt32ᐳᐳ : IEnumerableᐸIDependencyᐸInt32ᐳᐳ
ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ
IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- AbcDependencyᐸInt32ᐳ : IDependencyᐸInt32ᐳ
IEnumerableᐸIDependencyᐸInt32ᐳᐳ *-- XyzDependencyᐸInt32ᐳ : "Xyz" IDependencyᐸInt32ᐳ
IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : IDependencyᐸStringᐳ
Expand Down
2 changes: 1 addition & 1 deletion readme/enumerable.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "PerBlock" IEnumerableᐸIDependencyᐳ : IEnumerableᐸIDependencyᐳ
Service o-- "PerBlock" IEnumerableᐸIDependencyᐳ : IEnumerableᐸIDependencyᐳ
Composition ..> Service : IService Root
IEnumerableᐸIDependencyᐳ *-- AbcDependency : IDependency
IEnumerableᐸIDependencyᐳ *-- XyzDependency : 2 IDependency
Expand Down
2 changes: 1 addition & 1 deletion readme/func-with-arguments.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ classDiagram
class IService {
<<interface>>
}
Dependency o-- "Singleton" Clock : IClock
Dependency o-- "Singleton" Clock : IClock
Dependency *-- Int32 : Int32
FuncᐸInt32ˏIDependencyᐳ *-- Dependency : Dependency
Service *-- FuncᐸInt32ˏIDependencyᐳ : FuncᐸInt32ˏIDependencyᐳ
Expand Down
2 changes: 1 addition & 1 deletion readme/func-with-tag.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "PerResolve" FuncᐸIDependencyᐳ : "my tag" FuncᐸIDependencyᐳ
Service o-- "PerResolve" FuncᐸIDependencyᐳ : "my tag" FuncᐸIDependencyᐳ
Composition ..> Service : IService Root
FuncᐸIDependencyᐳ *-- Dependency : "my tag" IDependency
```
Expand Down
2 changes: 1 addition & 1 deletion readme/func.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
Service o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
Composition ..> Service : IService Root
FuncᐸIDependencyᐳ *-- Dependency : IDependency
```
Expand Down
2 changes: 1 addition & 1 deletion readme/keyed-service-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : "Dependency Key" IDependency
Service o-- "Singleton" Dependency : "Dependency Key" IDependency
Composition ..> Dependency : IDependency _
Composition ..> Service : IService _
```
Expand Down
2 changes: 1 addition & 1 deletion readme/lazy.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ classDiagram
}
Service *-- LazyᐸIDependencyᐳ : LazyᐸIDependencyᐳ
Composition ..> Service : IService Root
LazyᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
LazyᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
FuncᐸIDependencyᐳ *-- Dependency : IDependency
```

Expand Down
2 changes: 1 addition & 1 deletion readme/manually-started-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ classDiagram
TaskFactory *-- TaskScheduler : TaskScheduler
Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ
Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
TaskᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken"
FuncᐸIDependencyᐳ *-- Dependency : IDependency
```
Expand Down
2 changes: 1 addition & 1 deletion readme/onnewinstance-hint.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
3 changes: 1 addition & 2 deletions readme/partial-class.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,7 @@ classDiagram
<<interface>>
}
Service *-- String : "name with id" String
Service *-- Dependency : IDependency
Service *-- Dependency : IDependency
Service *-- "2 " Dependency : IDependency
Dependency *-- Int64 : Int64
Composition ..> Service : Service Root
```
Expand Down
8 changes: 3 additions & 5 deletions readme/perblock.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ classDiagram
class IDependency {
<<interface>>
}
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "PerBlock" Dependency : IDependency
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "PerBlock" Dependency : IDependency
Service o-- "PerBlock" Dependency : IDependency
Service o-- "PerBlock" Dependency : IDependency
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "2 PerBlock" Dependency : IDependency
Service o-- "2 PerBlock" Dependency : IDependency
Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
Composition ..> Service : Service Root
LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ
```

Expand Down
8 changes: 3 additions & 5 deletions readme/perresolve.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ classDiagram
class IDependency {
<<interface>>
}
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "PerResolve" Dependency : IDependency
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "PerResolve" Dependency : IDependency
Service o-- "PerResolve" Dependency : IDependency
Service o-- "PerResolve" Dependency : IDependency
ValueTupleᐸIDependencyˏIDependencyᐳ o-- "2 PerResolve" Dependency : IDependency
Service o-- "2 PerResolve" Dependency : IDependency
Service *-- LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
Composition ..> Service : Service Root
LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
LazyᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ o-- "PerResolve" FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ : FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ
FuncᐸValueTupleᐸIDependencyˏIDependencyᐳᐳ *-- ValueTupleᐸIDependencyˏIDependencyᐳ : ValueTupleᐸIDependencyˏIDependencyᐳ
```

Expand Down
4 changes: 2 additions & 2 deletions readme/scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ classDiagram
<<interface>>
}
Session *-- Composition : Composition
Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ
Service o-- "Scoped" Dependency : IDependency
Program o-- "PerResolve" FuncᐸSessionᐳ : FuncᐸSessionᐳ
Service o-- "Scoped" Dependency : IDependency
Composition ..> Service : IService SessionRoot
Composition ..> Program : Program ProgramRoot
FuncᐸSessionᐳ *-- Session : Session
Expand Down
2 changes: 1 addition & 1 deletion readme/service-collection.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : "Dependency Key" IDependency
Service o-- "Singleton" Dependency : "Dependency Key" IDependency
Composition ..> Dependency : IDependency _
Composition ..> Service : IService _
```
Expand Down
2 changes: 1 addition & 1 deletion readme/service-provider-with-scope.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Composition ..> Dependency : IDependency _
Composition ..> Service : IService _
```
Expand Down
2 changes: 1 addition & 1 deletion readme/service-provider.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Composition ..> Dependency : IDependency _
Composition ..> Service : IService _
```
Expand Down
6 changes: 3 additions & 3 deletions readme/simplified-binding.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ classDiagram
class IOtherDependency {
<<interface>>
}
Service o-- "PerBlock" Dependency : Dependency
Service o-- "PerBlock" Dependency : IDependency
Service o-- "PerBlock" Dependency : IOtherDependency
Service o-- "PerBlock" Dependency : Dependency
Service o-- "PerBlock" Dependency : IDependency
Service o-- "PerBlock" Dependency : IOtherDependency
Composition ..> Service : Service MyService
```

Expand Down
3 changes: 1 addition & 2 deletions readme/singleton.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "Singleton" Dependency : IDependency
Service o-- "Singleton" Dependency : IDependency
Service o-- "2 Singleton" Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
2 changes: 1 addition & 1 deletion readme/tag-type.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ classDiagram
<<interface>>
}
Service *-- AbcDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.AbcDependency) IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.XyzDependency) IDependency
Service o-- "Singleton" XyzDependency : typeof(Pure.DI.UsageTests.Advanced.TagTypeScenario.XyzDependency) IDependency
Service *-- AbcDependency : IDependency
Composition ..> Service : IService Root
Composition ..> XyzDependency : IDependency XyzRoot
Expand Down
2 changes: 1 addition & 1 deletion readme/tag-unique.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ classDiagram
<<interface>>
}
Composition ..> ServiceᐸStringᐳ : IServiceᐸStringᐳ Root
ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ
ServiceᐸStringᐳ o-- "PerBlock" IEnumerableᐸIDependencyᐸStringᐳᐳ : IEnumerableᐸIDependencyᐸStringᐳᐳ
IEnumerableᐸIDependencyᐸStringᐳᐳ *-- AbcDependencyᐸStringᐳ : Unique tag 1 IDependencyᐸStringᐳ
IEnumerableᐸIDependencyᐸStringᐳᐳ *-- XyzDependencyᐸStringᐳ : Unique tag 2 IDependencyᐸStringᐳ
```
Expand Down
2 changes: 1 addition & 1 deletion readme/tags.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ classDiagram
<<interface>>
}
Service *-- AbcDependency : "Abc" IDependency
Service o-- "Singleton" XyzDependency : "Xyz" IDependency
Service o-- "Singleton" XyzDependency : "Xyz" IDependency
Service *-- AbcDependency : IDependency
Composition ..> XyzDependency : IDependency XyzRoot
Composition ..> Service : IService Root
Expand Down
4 changes: 2 additions & 2 deletions readme/task.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ classDiagram
TaskFactory *-- TaskScheduler : TaskScheduler
Service *-- TaskᐸIDependencyᐳ : TaskᐸIDependencyᐳ
Composition ..> Service : IService GetRoot(System.Threading.CancellationToken cancellationToken)
TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
TaskᐸIDependencyᐳ o-- "PerBlock" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ
TaskᐸIDependencyᐳ o-- "PerResolve" FuncᐸIDependencyᐳ : FuncᐸIDependencyᐳ
TaskᐸIDependencyᐳ o-- "PerBlock" TaskFactoryᐸIDependencyᐳ : TaskFactoryᐸIDependencyᐳ
FuncᐸIDependencyᐳ *-- Dependency : IDependency
TaskFactoryᐸIDependencyᐳ o-- CancellationToken : Argument "cancellationToken"
TaskFactoryᐸIDependencyᐳ *-- TaskCreationOptions : TaskCreationOptions
Expand Down
4 changes: 2 additions & 2 deletions readme/tracking-async-disposable-instances-in-delegates.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,9 @@ classDiagram
class IAsyncDisposable {
<<interface>>
}
Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ
Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ
Composition ..> Service : Service Root
FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ
FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ
OwnedᐸIDependencyᐳ *-- Owned : Owned
OwnedᐸIDependencyᐳ *-- Dependency : IDependency
```
Expand Down
4 changes: 2 additions & 2 deletions readme/tracking-disposable-instances-in-delegates.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ classDiagram
class IService {
<<interface>>
}
Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ
Service o-- "PerResolve" FuncᐸOwnedᐸIDependencyᐳᐳ : FuncᐸOwnedᐸIDependencyᐳᐳ
Composition ..> Service : Service Root
FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ
FuncᐸOwnedᐸIDependencyᐳᐳ o-- "PerBlock" OwnedᐸIDependencyᐳ : OwnedᐸIDependencyᐳ
OwnedᐸIDependencyᐳ *-- Owned : Owned
OwnedᐸIDependencyᐳ *-- Dependency : IDependency
```
Expand Down
3 changes: 1 addition & 2 deletions readme/transient.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ classDiagram
class IService {
<<interface>>
}
Service *-- Dependency : IDependency
Service *-- Dependency : IDependency
Service *-- "2 " Dependency : IDependency
Composition ..> Service : IService Root
```

Expand Down
35 changes: 26 additions & 9 deletions src/Pure.DI.Core/Core/Code/ClassDiagramBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public LinesBuilder Build(CompositionCode composition)
lines.AppendLine("}");
}

foreach (var dependency in graph.Edges)
foreach (var (dependency, count) in graph.Edges.GroupBy(i => i).Select(i => (dependency: i.First(), count: i.Count())))
{
cancellationToken.ThrowIfCancellationRequested();
if (dependency.Target.Root is not null && rootProperties.TryGetValue(dependency.Injection, out var root))
Expand All @@ -149,7 +149,7 @@ public LinesBuilder Build(CompositionCode composition)
}

var relationship = dependency.Source.Lifetime == Lifetime.Transient ? "*--" : "o--";
lines.AppendLine($"{FormatType(dependency.Target.Type, DefaultFormatOptions)} {relationship} {FormatCardinality(dependency.Source.Lifetime)} {FormatType(dependency.Source.Type, DefaultFormatOptions)} : {FormatDependency(dependency, DefaultFormatOptions)}");
lines.AppendLine($"{FormatType(dependency.Target.Type, DefaultFormatOptions)} {relationship} {FormatCardinality(count, dependency.Source.Lifetime)} {FormatType(dependency.Source.Type, DefaultFormatOptions)} : {FormatDependency(dependency, DefaultFormatOptions)}");
}
}
}
Expand Down Expand Up @@ -177,13 +177,30 @@ private string FormatRoot(Root root)
return $"{FormatType(root.Injection.Type, DefaultFormatOptions)} {displayName}{typeArgsStr}{rootArgsStr}";
}

private static string FormatCardinality(Lifetime lifetime) =>
lifetime switch
[SuppressMessage("ReSharper", "InvertIf")]
private static string FormatCardinality(int count, Lifetime lifetime)
{
var cardinality = new StringBuilder();
if (count > 1)
{
Lifetime.Transient => "",
_ => $" \\\"{lifetime}\\\""
};

cardinality.Append(count);
cardinality.Append(' ');
}

if (lifetime != Lifetime.Transient)
{
cardinality.Append(lifetime);
}

if (cardinality.Length > 0)
{
cardinality.Insert(0, "\\\"");
cardinality.Append("\\\"");
}

return cardinality.ToString();
}

private string FormatDependency(Dependency dependency, FormatOptions options) =>
$"{(dependency.Injection.Tag == default ? "" : FormatTag(dependency.Injection.Tag) + " ")}{FormatSymbol(dependency.Injection.Type, options)}";

Expand Down Expand Up @@ -266,7 +283,7 @@ private record FormatOptions(
string StartGenericArgsSymbol = "ᐸ",
string FinishGenericArgsSymbol = "ᐳ",
string TypeArgsSeparator = "ˏ");

private class ClassDiagramWalker(ClassDiagramBuilder builder, LinesBuilder lines, FormatOptions options)
: DependenciesWalker<Unit>
{
Expand Down

0 comments on commit 811e374

Please sign in to comment.