========================= **providedValue** element ========================= The ``providedValue`` element is used to inject values that are resolved at runtime through custom logic rather than being hardcoded in the XML or resolved directly from the DI container. This is particularly useful for injecting external dependencies like loggers, session data, or environment-specific values. .. note:: Refer to :doc:`../../sample-files/IoCConfiguration_providedValue.generated` for more examples on **providedValue** element as well as related unit tests in `ProvidedValue tests `_ for more examples. How it Works ------------ When the configuration parser encounters a ``providedValue`` element, it attempts to resolve the value using a list of ``IValueProvider`` implementations passed during the initialization of the ``FileBasedConfiguration``. Setup in C# ~~~~~~~~~~~ To use ``providedValue``, you must initialize the ``ValueProviders`` property in ``IoC.Configuration.DiContainerBuilder.FileBased.FileBasedConfigurationParameters``. .. code-block:: csharp // Example setup for ValueProviders var configurationParameters = new FileBasedConfigurationParameters( configurationFileContentsProvider, entryAssemblyFolder, loadedAssemblies) { // Initialize the list of value providers ValueProviders = new List { new MyCustomValueProvider(logger) } }; // Use configurationParameters to build the DiContainer The ``IValueProvider`` interface requires implementing ``TryResolveValue``, which receives information about the target (type, name, and whether it's a parameter, property, or setting) to provide the appropriate object. XML Configuration Examples -------------------------- The ``providedValue`` element can be used for module parameters, service constructor arguments, properties, and settings. 1. Injection into Modules ~~~~~~~~~~~~~~~~~~~~~~~~~ You can pass externally provided values into DI modules. This is useful for passing a pre-configured logger to a module that needs to register it. .. code-block:: xml 2. Injection into Services and Properties ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ It can be used within ```` to inject dependencies into constructors or via property injection. .. code-block:: xml 3. Usage in Settings ~~~~~~~~~~~~~~~~~~~~ ``providedValue`` can also define application settings that are resolved at runtime. .. code-block:: xml 4. Plugin Support ~~~~~~~~~~~~~~~~~ Plugins can also leverage provided values for their own initialization and settings. .. code-block:: xml :linenos: