Structr
  • Welcome
  • Utilities
    • Abstractions
      • Check
      • Ensure
      • Money
      • HierarchyId
      • Providers
        • SequentialGuidProvider
      • Extensions
        • DateTime
        • Dictionary
        • DirectoryInfo
        • Enumerable
        • Enum
        • Expression
        • Int
        • Long
        • MemberInfo
        • Object
        • Queryable
        • ServiceCollection
        • String
        • Type
      • Helpers
        • AsyncHelper
        • BindHelper
      • JsonConverters
        • DateOnly
        • TimeOnly
        • StringNumber
    • Collections
      • AutoMapper extensions
    • IO
      • FileHelper
      • MimeTypeHelper
      • PathHelper
      • SequentialFileName
    • Configuration
      • Providers
        • JSON-file
        • XML-file
        • In-Memory
        • Consul
      • Get settings
      • Set settings
      • Customization
    • Email
      • Razor
    • Navigation
      • Menu
      • Breadcrumbs
    • Security
  • Domain
    • Domain
      • Entities
      • Value objects
  • Data Access
    • Entity Framework Core
    • Entity Framework 6
  • Use Cases
    • Operations
      • Filtering
      • Decoration
    • Notices
    • Validation
    • Specifications
    • Stateflows
      • StateMachine
      • Configurations
  • Presentation
    • ASP.NET Core
      • Client
      • Http
      • JavaScript
      • Json
      • Mvc
      • Referrer
      • Rewrite
      • Routing
      • TagHelpers
      • Validation
Powered by GitBook
On this page

Was this helpful?

Edit on GitHub
  1. Utilities
  2. Configuration
  3. Providers

XML-file

XmlSettingsProvider provides functionality for access to a XML-file with settings.

Setup

Create settings class.

public class SmtpEmailSettings
{
    public string Host { get; set; }
    public int Port { get; set; }
}

Create XML file with settings:

<?xml version="1.0" encoding="utf-16"?>
<SmtpEmailSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <Host>smtp.example.com</Host>
  <Port>25</Port>
</SmtpEmailSettings>

Setup XML-file settings provider:

services.AddConfiguration()
    .AddXml<SmtpEmailSettings>("path_to_xml_file");
PreviousJSON-fileNextIn-Memory

Last updated 2 years ago

Was this helpful?