diff options
Diffstat (limited to 'lib/Plugins')
-rw-r--r-- | lib/Plugins/src/Attributes/ConfigurationInitalizerAttribute.cs | 1 | ||||
-rw-r--r-- | lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs | 58 | ||||
-rw-r--r-- | lib/Plugins/src/IPlugin.cs | 7 | ||||
-rw-r--r-- | lib/Plugins/src/VNLib.Plugins.csproj | 4 |
4 files changed, 69 insertions, 1 deletions
diff --git a/lib/Plugins/src/Attributes/ConfigurationInitalizerAttribute.cs b/lib/Plugins/src/Attributes/ConfigurationInitalizerAttribute.cs index f214d2b..6903902 100644 --- a/lib/Plugins/src/Attributes/ConfigurationInitalizerAttribute.cs +++ b/lib/Plugins/src/Attributes/ConfigurationInitalizerAttribute.cs @@ -27,6 +27,7 @@ using System.Text.Json; namespace VNLib.Plugins.Attributes { + /// <summary> /// Set this attribute on an <see cref="IPlugin"/> instance method to define the configuration initializer. /// This attribute can only be defined on a single instance method and cannot be overloaded. diff --git a/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs b/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs new file mode 100644 index 0000000..e922e9d --- /dev/null +++ b/lib/Plugins/src/Attributes/ServiceConfiguratorAttribute.cs @@ -0,0 +1,58 @@ +/* +* Copyright (c) 2023 Vaughn Nugent +* +* Library: VNLib +* Package: VNLib.Plugins +* File: ServiceConfiguratorAttribute.cs +* +* ServiceConfiguratorAttribute.cs is part of VNLib.Plugins which is part of the larger +* VNLib collection of libraries and utilities. +* +* VNLib.Plugins is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published +* by the Free Software Foundation, either version 2 of the License, +* or (at your option) any later version. +* +* VNLib.Plugins is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with VNLib.Plugins. If not, see http://www.gnu.org/licenses/. +*/ + +using System; +using System.ComponentModel.Design; + +namespace VNLib.Plugins.Attributes +{ + /// <summary> + /// <para> + /// Set this attribute on an <see cref="IPlugin"/> instance method to define the service configuration + /// method. When declated, allows the plugin to expose shared types to the host + /// </para> + /// <para> + /// This method may be runtime dependant, it may not be called on all platforms, and it + /// may not be required. + /// </para> + /// <para> + /// Lifecycle: This method may be called by the runtime anytime after the <see cref="IPlugin.Load"/> + /// method, its exposed services are considered invalid after the <see cref="IPlugin.Unload"/> + /// method is called. + /// </para> + /// <para> + /// Method signature: <code>void OnServiceConfiguration(<see cref="IServiceContainer"/> container)</code> + /// </para> + /// </summary> + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)] + public sealed class ServiceConfiguratorAttribute : Attribute + {} + + /// <summary> + /// A safe delegate that matches the signature of the <see cref="ServiceConfiguratorAttribute"/> + /// method exposed + /// </summary> + /// <param name="sender"></param> + public delegate void ServiceConfigurator(IServiceContainer sender); +} diff --git a/lib/Plugins/src/IPlugin.cs b/lib/Plugins/src/IPlugin.cs index 16bd403..d872232 100644 --- a/lib/Plugins/src/IPlugin.cs +++ b/lib/Plugins/src/IPlugin.cs @@ -1,5 +1,5 @@ /* -* Copyright (c) 2022 Vaughn Nugent +* Copyright (c) 2023 Vaughn Nugent * * Library: VNLib * Package: VNLib.Plugins @@ -48,6 +48,11 @@ namespace VNLib.Plugins /// Returns all endpoints within the plugin to load into the current root /// </summary> /// <returns>An enumeration of endpoints to load</returns> + /// <remarks> + /// Lifecycle: Results returned from this method should be consistant (although its only + /// likely to be called once) anytime after the <see cref="Load"/> method, and undefined + /// after the <see cref="Unload"/> method is called. + /// </remarks> IEnumerable<IEndpoint> GetEndpoints(); } }
\ No newline at end of file diff --git a/lib/Plugins/src/VNLib.Plugins.csproj b/lib/Plugins/src/VNLib.Plugins.csproj index 062e7a4..6bb5cee 100644 --- a/lib/Plugins/src/VNLib.Plugins.csproj +++ b/lib/Plugins/src/VNLib.Plugins.csproj @@ -45,4 +45,8 @@ </None> </ItemGroup> + <ItemGroup> + <Folder Include="Services\" /> + </ItemGroup> + </Project> |