Page tree
Skip to end of metadata
Go to start of metadata

Create a new ASP.NET Core project

Becoming a superhero is a fairlystraight forward process:

Add an XML file on your project. If you prefer can set this file as an embedded resource, or set to copy to build location, use the F4 shortcut on Solution Explorer to do that.

The base structure of Oragon.Spring XML is present bellow:

<?xml version="1.0" encoding="utf-8" ?>
<objects
    xmlns="http://www.springframework.net"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xmlns:aop="http://www.springframework.net/aop"
>


    <object name="GetLogsRetryCount" type="System.Int32" factory-method="Parse">
        <constructor-arg index="0" value="20" />
    </object>

    <object name="GetLogsWaitTime" type="System.TimeSpan">
        <constructor-arg name="hours" value="0" />
        <constructor-arg name="minutes" value="0" />
        <constructor-arg name="seconds" value="30" />
    </object>
 
</objects>
 

On this example, I'm configuring a factory for an Int32 and a TimeSpan called respectively GetLogsRetryCount and GetLogsWaitTime.

Use Package Manager Console

Package Manager Console
PM> Install-Package "Oragon.Spring.Extensions.DependencyInjection"

This package add Oragon.Spring.Core as a dependency.

Once you're strong enough, save the world:

public class Startup
{


    ...


    public IServiceProvider ConfigureServices(IServiceCollection services)
    {
        
        ...
        
        return services.WithSpring(
            "assembly://[assemblyname]/[namespace]/filename1.xml", //Embedded resource
            "./filename2.xml", //Relative to Binary on execution folder
            
        );
    }
    
    ...
    
}


ASP.NET Controllers can be suppressed from spring XML configuration because the Spring Container has a fallback DI container.

The project Oragon.Spring.Core.AspNetCoreTest is a Oragon.Spring full featured example.


Table of Contents

  • No labels