Create empty C# class library project, install app server sdk nuget package
Install-Package Inceptum.AppServer.Sdk
This will download required nuget packages and add references to assemblies
Application MUST
- have one class which implements IHostedApplication
- have its assembly marked with HostedApplication attribute
- have nuspec file with tag Inceptum.AppServer.Application
Application CAN
- declare any number of public classes which implement IWindsorInstaller, all of them will be installed into container on application start;
To achive all above please create following files under project root folder:
- Application.cs
-
$ProjectName$ .nuspec - make sure that the name of nuspec is the same as the name of the csproj - Windsor\ApplicationInstaller.cs
- Properties\ApplicationInfo.cs
using System;
using Castle.Core.Logging;
using Inceptum.AppServer;
namespace YOUR.NAMESPACE
{
class HostedApplication : IHostedApplication
{
private readonly ILogger m_Logger;
public HostedApplication(ILogger logger)
{
/* NOTE: logger and other application dependencies are resolved from container
install components you need via Windsor\ApplicationInstaller.cs installer */
if (logger == null) throw new ArgumentNullException("logger");
m_Logger = logger;
}
public void Start()
{
/*TODO: implement application start logic here, or leave it empty and
create components using IStartable interface from StartableFacility*/
m_Logger.Debug("Start method of {0} was called" + GetType().Name);
throw new NotImplementedException();
}
}
}
<?xml version="1.0"?>
<package >
<metadata>
<id>YOUR.PACKAGE.ID</id>
<version>$version$</version>
<title>YOUR.PACKAGE.ID</title>
<authors>TODO set authors</authors>
<owners>TODO set owners</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>TODO describe application</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2013</copyright>
<tags>Inceptum.AppServer.Application</tags>
</metadata>
</package>
using System;
using Castle.Facilities.Startable;
using Castle.Facilities.TypedFactory;
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.Resolvers.SpecializedResolvers;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using Inceptum.AppServer.Configuration;
namespace YOUR.NAMESPACE.Windsor
{
public class HostedApplicationInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
/*Add default components commonly used, you can remove registrations if you don't need it*/
container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));
container.AddFacility<StartableFacility>(f => {});
container.AddFacility<TypedFactoryFacility>();
/*TODO: you can configure transports like this
container.AddFacility<ConfigurationFacility>(f => f.Configuration("configuration")
.ConfigureTransports("transports", "{environment}", "{machineName}")
.ConfigureConnectionStrings("transports", "{environment}", "{machineName}"));
*/
/*TODO: configure and install required components into windsor container */
}
}
}
using Inceptum.AppServer;
[assembly: HostedApplication("YOUR.PACKAGE.ID")]