add a scanner, but this seems to be a wrong solution. Change open-source head

This commit is contained in:
Youmu Liu
2026-07-07 18:20:38 +08:00
parent b053567eb7
commit 1705d7c245
276 changed files with 3468 additions and 7205 deletions
+33 -36
View File
@@ -1,30 +1,10 @@
//-----------------------------------------------------------------------
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------------
// file="IStaticModule"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
// Copyright (c) Nitload.
// SPDX-License-Identifier: MIT
// -----------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
@@ -50,7 +30,9 @@ namespace StgSharp
/// The configuration profile supplied at registration time. Use <see
/// cref="IModuleInitializeProfile.Empty" /> if no configuration is required.
/// </param>
void InitializeModule(IModuleInitializeProfile profile);
void InitializeModule(
IModuleInitializeProfile profile
);
/// <summary>
/// Releases all resources acquired during <see cref="InitializeModule" />. Implementations should
@@ -98,12 +80,18 @@ namespace StgSharp
/// Initializes a new <see cref="ModuleDescriptor" /> using <see
/// cref="IModuleInitializeProfile.Empty" /> as the profile.
/// </summary>
public ModuleDescriptor(IStaticModule module) : this(module, IModuleInitializeProfile.Empty) { }
public ModuleDescriptor(
IStaticModule module
)
: this(module, IModuleInitializeProfile.Empty) { }
/// <summary>
/// Initializes a new <see cref="ModuleDescriptor" /> with an explicit profile.
/// </summary>
public ModuleDescriptor(IStaticModule module, IModuleInitializeProfile profile)
public ModuleDescriptor(
IStaticModule module,
IModuleInitializeProfile profile
)
{
Module = module;
Profile = profile;
@@ -139,15 +127,17 @@ namespace StgSharp
/// <summary>
/// An ordered collection of modules to be initialized during application startup and
/// uninitialized on shutdown. Supports three registration strategies so that the <c>new()</c>
/// generic constraint is never a hard requirement.
/// uninitialized on shutdown. Supports three registration strategies so that the <c> new()
/// </c> generic constraint is never a hard requirement.
/// </summary>
public sealed class ModuleToInitializeCollection : IEnumerable<IStaticModule>, IStaticModule
{
private readonly List<ModuleDescriptor> _descriptors = [];
internal ModuleToInitializeCollection(World.Initializer i)
internal ModuleToInitializeCollection(
World.Initializer i
)
{
_descriptors.Add(new ModuleDescriptor(i));
}
@@ -202,8 +192,9 @@ namespace StgSharp
/// Optional initialization profile. Defaults to <see
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
/// </param>
public ModuleToInitializeCollection UseModule<T>(IModuleInitializeProfile? profile = null)
where T: IStaticModule, new()
public ModuleToInitializeCollection UseModule<T>(
IModuleInitializeProfile? profile = null
) where T : IStaticModule, new()
{
return UseModule(static() => new T(), profile);
}
@@ -225,7 +216,8 @@ namespace StgSharp
/// </param>
public ModuleToInitializeCollection UseModule(
Func<IStaticModule> factory,
IModuleInitializeProfile? profile = null)
IModuleInitializeProfile? profile = null
)
{
if (factory is null) {
return this;
@@ -251,7 +243,10 @@ namespace StgSharp
/// Optional initialization profile. Defaults to <see
/// cref="IModuleInitializeProfile.Empty" /> when <see langword="null" />.
/// </param>
public ModuleToInitializeCollection UseModule(IStaticModule module, IModuleInitializeProfile? profile = null)
public ModuleToInitializeCollection UseModule(
IStaticModule module,
IModuleInitializeProfile? profile = null
)
{
_descriptors.Add(new ModuleDescriptor(
module,
@@ -272,7 +267,9 @@ namespace StgSharp
/// cref="InitializeModule()" />, ignoring the supplied profile because each contained module uses
/// its own registered profile.
/// </summary>
void IStaticModule.InitializeModule(IModuleInitializeProfile profile)
void IStaticModule.InitializeModule(
IModuleInitializeProfile profile
)
{
InitializeModule();
}