Compare commits
4 Commits
v0.0.1.2-a
...
v0.0.1.4-a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
debedc837e | ||
|
|
d0ccdbfa0f | ||
|
|
16d0142967 | ||
|
|
b06e886cf2 |
@@ -11,16 +11,19 @@ jobs:
|
|||||||
timeout-minutes: 5
|
timeout-minutes: 5
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v5
|
||||||
- name: Setup .NET SDK
|
- name: Setup .NET SDK
|
||||||
uses: actions/setup-dotnet@v4
|
uses: actions/setup-dotnet@v5
|
||||||
with:
|
with:
|
||||||
dotnet-version: 9.x
|
dotnet-version: |
|
||||||
|
10.x
|
||||||
|
9.x
|
||||||
|
8.x
|
||||||
- name: Build
|
- name: Build
|
||||||
run: dotnet build Syrette -c Release
|
run: dotnet build Syrette -c Release
|
||||||
#- name: Test
|
#- name: Test
|
||||||
# run: dotnet test -c Release --no-build
|
# run: dotnet test -c Release --no-build
|
||||||
- name: Pack nugets
|
- name: Pack nugets
|
||||||
run: dotnet pack Syrette -c Release --no-build --output . --include-symbols --include-source
|
run: dotnet pack Syrette -c Release --no-build --output . --include-symbols --include-source -p:SymbolPackageFormat=snupkg
|
||||||
- name: Push to NuGet
|
- name: Push to NuGet
|
||||||
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGETAPIKEY}} --source https://api.nuget.org/v3/index.json
|
run: dotnet nuget push "*.nupkg" --api-key ${{secrets.NUGETAPIKEY}} --source https://api.nuget.org/v3/index.json
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class GuidDependantService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void LogWithId(string message) {
|
public void LogWithId(string message) {
|
||||||
logService.Log($"[GuidDependantService] {message} (ID: {guidService.Id})");
|
logService.Log($"[GuidDependantService] {message} (ID: {guidService?.Id})");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,29 @@ public class ServiceContainer {
|
|||||||
/// <typeparam name="TInterface">Interface the service is implementing</typeparam>
|
/// <typeparam name="TInterface">Interface the service is implementing</typeparam>
|
||||||
/// <typeparam name="TImplementation">Implementation type of the service</typeparam>
|
/// <typeparam name="TImplementation">Implementation type of the service</typeparam>
|
||||||
public ServiceContainer AddSingleton<TInterface, TImplementation>()
|
public ServiceContainer AddSingleton<TInterface, TImplementation>()
|
||||||
|
where TInterface : class
|
||||||
where TImplementation : class, TInterface {
|
where TImplementation : class, TInterface {
|
||||||
descriptors.Add(new ServiceDescriptor {
|
descriptors.Add(new () {
|
||||||
ServiceType = typeof(TInterface),
|
ServiceType = typeof(TInterface),
|
||||||
ImplementationType = typeof(TImplementation),
|
ImplementationType = typeof(TImplementation),
|
||||||
Lifetime = ServiceLifetime.Lifetime
|
Lifetime = ServiceLifetime.Lifetime
|
||||||
});
|
});
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a singleton service where the service type is the same as the implementation type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TClass">Class type of the service</typeparam>
|
||||||
|
public ServiceContainer AddSingleton<TClass>()
|
||||||
|
where TClass : class {
|
||||||
|
descriptors.Add(new () {
|
||||||
|
ServiceType = typeof(TClass),
|
||||||
|
ImplementationType = typeof(TClass),
|
||||||
|
Lifetime = ServiceLifetime.Lifetime
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registers a transient service with its implementation.
|
/// Registers a transient service with its implementation.
|
||||||
@@ -39,8 +54,9 @@ public class ServiceContainer {
|
|||||||
/// <typeparam name="TInterface">Interface the service is implementing</typeparam>
|
/// <typeparam name="TInterface">Interface the service is implementing</typeparam>
|
||||||
/// <typeparam name="TImplementation">Implementation type of the service</typeparam>
|
/// <typeparam name="TImplementation">Implementation type of the service</typeparam>
|
||||||
public ServiceContainer AddTransient<TInterface, TImplementation>()
|
public ServiceContainer AddTransient<TInterface, TImplementation>()
|
||||||
|
where TInterface : class
|
||||||
where TImplementation : class, TInterface {
|
where TImplementation : class, TInterface {
|
||||||
descriptors.Add(new ServiceDescriptor {
|
descriptors.Add(new () {
|
||||||
ServiceType = typeof(TInterface),
|
ServiceType = typeof(TInterface),
|
||||||
ImplementationType = typeof(TImplementation),
|
ImplementationType = typeof(TImplementation),
|
||||||
Lifetime = ServiceLifetime.Transient
|
Lifetime = ServiceLifetime.Transient
|
||||||
@@ -48,6 +64,20 @@ public class ServiceContainer {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Registers a transient service where the service type is the same as the implementation type.
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="TClass">Class type of the service</typeparam>
|
||||||
|
public ServiceContainer AddTransient<TClass>()
|
||||||
|
where TClass : class {
|
||||||
|
descriptors.Add(new () {
|
||||||
|
ServiceType = typeof(TClass),
|
||||||
|
ImplementationType = typeof(TClass),
|
||||||
|
Lifetime = ServiceLifetime.Transient
|
||||||
|
});
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
// you can't call generic methods with an unknown type at compile time
|
// you can't call generic methods with an unknown type at compile time
|
||||||
// so we use reflection to call the generic GetService<T> method with the provided type
|
// so we use reflection to call the generic GetService<T> method with the provided type
|
||||||
// Basically we build the method GetService<serviceType>() at runtime and then call it.
|
// Basically we build the method GetService<serviceType>() at runtime and then call it.
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.0.1.2-alpha</Version>
|
<Version>0.0.1.4-alpha</Version>
|
||||||
<Title>Syrette </Title>
|
<Title>Syrette </Title>
|
||||||
<Authors>Lorefice Samuele</Authors>
|
<Authors>Lorefice Samuele</Authors>
|
||||||
<Description>Syrette is a minimalistic dependency injection library for C#. It aims to provide a simple and efficient way to achieve dependency injections in your applications without the overhead of larger frameworks.</Description>
|
<Description>Syrette is a minimalistic dependency injection library for C#. It aims to provide a simple and efficient way to achieve dependency injections in your applications without the overhead of larger frameworks.</Description>
|
||||||
@@ -23,7 +23,9 @@
|
|||||||
<Company>Samuele Lorefice</Company>
|
<Company>Samuele Lorefice</Company>
|
||||||
<Deterministic>true</Deterministic>
|
<Deterministic>true</Deterministic>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<TargetFrameworks>net9.0;net8.0</TargetFrameworks>
|
<TargetFrameworks>net8.0;net9.0;net10.0</TargetFrameworks>
|
||||||
|
<EmbedUntrackedSources>true</EmbedUntrackedSources>
|
||||||
|
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
|
||||||
<DebugSymbols>true</DebugSymbols>
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"sdk": {
|
"sdk": {
|
||||||
"version": "9.0.0",
|
"version": "10.0.0",
|
||||||
"rollForward": "latestMinor",
|
"rollForward": "latestMinor",
|
||||||
"allowPrerelease": false
|
"allowPrerelease": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user