-
-
Notifications
You must be signed in to change notification settings - Fork 534
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Properties and method from inheritance chain. Making it work with ext…
…ensions.
- Loading branch information
1 parent
58113e6
commit 6892987
Showing
10 changed files
with
199 additions
and
46 deletions.
There are no files selected for viewing
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
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
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
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
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
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
45 changes: 45 additions & 0 deletions
45
Source/SourceGenerators/Blazorise.ApiDocsDtos/ComponentsApiDocsSource.cs
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,45 @@ | ||
namespace Blazorise; | ||
|
||
|
||
public interface IComponentsApiDocsSource | ||
{ | ||
Dictionary<Type, ApiDocsForComponent> Components { get; } | ||
} | ||
|
||
public class ComponentsApiDocsSource | ||
{ | ||
public Dictionary<Type, ApiDocsForComponent> Components { get; } | ||
|
||
private static readonly Lazy<ComponentsApiDocsSource> instance = new(() => new ComponentsApiDocsSource()); | ||
public static ComponentsApiDocsSource Instance => instance.Value; | ||
|
||
private ComponentsApiDocsSource() | ||
{ | ||
Components = new Dictionary<Type, ApiDocsForComponent>(); | ||
|
||
// Find all types implementing IComponentsApiDocsSource | ||
var sources = AppDomain.CurrentDomain.GetAssemblies() | ||
.SelectMany(assembly => assembly.GetTypes()) | ||
.Where(type => typeof(IComponentsApiDocsSource).IsAssignableFrom(type) && type is { IsInterface: false, IsAbstract: false }); | ||
|
||
foreach (var sourceType in sources) | ||
{ | ||
// Create an instance of the source type | ||
if ( Activator.CreateInstance( sourceType ) is not IComponentsApiDocsSource sourceInstance ) | ||
continue; | ||
// Merge Components dictionary | ||
foreach (var component in sourceInstance.Components) | ||
{ | ||
if (!Components.ContainsKey(component.Key)) | ||
{ | ||
Components[component.Key] = component.Value; | ||
} | ||
else | ||
{ | ||
// Handle duplicates if needed, e.g., log or overwrite | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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
Oops, something went wrong.