An IRC Client library
== Usage ==
In-depth knowledge of [[ https://github.com/castleproject/Windsor/blob/master/docs/README.md | Castle Windsor ]] is assumed here.
Grab yourself the following [[ https://docs.microsoft.com/en-us/nuget/what-is-nuget | NuGet ]] packages:
``` lang=xml
<package id="Castle.Core-log4net" version="4.2.1" targetFramework="net45" />
<package id="Castle.LoggingFacility" version="4.1.0" targetFramework="net45" />
<package id="Stwalkerster.IrcClient" version="7.0.11" targetFramework="net45" />
<!-- these should be installed as dependencies of the above -->
<package id="Castle.Core" version="4.2.1" targetFramework="net45" />
<package id="Castle.Windsor" version="4.1.0" targetFramework="net45" />
<package id="log4net" version="2.0.8" targetFramework="net45" />
```
Create yourself a basic [[ https://github.com/castleproject/Windsor/blob/master/docs/installers.md | installer ]]:
``` lang=csharp
public class Installer : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.AddFacility<LoggingFacility>(f => f.LogUsing<Log4netFactory>().WithConfig("log4net.xml"));
container.AddFacility<StartableFacility>(x => x.DeferredStart());
container.Register(
Component.For<ISupportHelper>().ImplementedBy<SupportHelper>(),
Component.For<IIrcConfiguration>().Instance(new IrcConfiguration(/* ... */)),
Component.For<IIrcClient>().ImplementedBy<IrcClient>().Start()
);
}
}
```
Configure log4net.
Finally, grab your IRC client from the container:
``` lang=csharp
var windsorContainer = new WindsorContainer();
windsorContainer.Install(FromAssembly.This());
var ircClient = windsorContainer.Resolve<IIrcClient>();
```
Remember that the IRC client implements [[ https://github.com/castleproject/Windsor/blob/master/docs/startable-facility.md | IStartable ]], so it's probably better to register a managing class, and feed the client in as a dependency:
``` lang=csharp
public class Program
{
public Program(IIrcClient client)
{
client.JoinChannel("#en.wikipedia");
}
}
```
If you do this, remember to register the `Program` component in your installer:
``` lang=csharp
Component.For<Program>(),
```