Class handler system Since I had a lot of classes to store inside 1 main class I decided to create a handler system. I was having to create 30 - 50 private readonly fields for private instances of classes, then assigning them all in the constructor, then creating a public method to get them via a return. I decided instead of having up to 150 lines of code that I would try and sort out a more organised system and put it in place.

I start by declaring an empty interface for all my handlers to inherit  that interface. This interface is in a totally seperate .cs file.

namespace Panda.Root.Core.Other
{
    public interface IPandaClass { }
}


Now, I declare a new dictionary in my main class (PandaServer.cs)

private readonly Dictionary&lt;string, IPandaClass&gt; _handlers;


I then assign the dictionary:

public PandaServer()
{
    _handlers = new Dictionary&lt;string, IPandaClass&gt;(StringComparer.InvariantCultureIgnoreCase);
}


I create two methods, one for registering new handlers (or replacing them) and one for returning the handler by name.

private void RegisterHandler(string handlerName, IPandaClass handler)
{
    _handlers[handlerName] = handler;
}

public IPandaClass GetHandler(string handlerName)
{
    return _handlers[handlerName];
}


And then I can register as many hadlers as I can, pretty easily:

RegisterHandler("messages", Utilities.CreateInstanceOf&lt;MessageHandler&gt;());
RegisterHandler("configuration", Utilities.CreateInstanceOf&lt;ConfigurationManager&gt;());
RegisterHandler("console_worker", Utilities.CreateInstanceOf&lt;ConsoleWorker&gt;());
RegisterHandler("base_handler", Utilities.CreateInstanceOf&lt;BaseHandler&gt;());


I then declare them where I need them like this

var panda = Program.GetPandaServer();
var pandaBase = panda.GetHandler("base") as BaseHandler;

if (pandaBase == null)
{
    return;
}

var playerHandler = pandaBase.GetHandler("player") as PlayerHandler;


I was told declaring all your classes there instead of making multiple calls in future was better as you would always have that variable there incase you wanted to make multiple calls to the same method or methods of that method's return type.

The only major bad things I see with this system is you're hardcoding the name of the handlers but I guess there isn't a way around that, its how it works. If anyone can think of any other improvements please let me know.
IServiceProvider
So you decided to reinvent the IServiceProvider Interface :-) which

Defines a mechanism for retrieving a service object; that is, an object that provides custom support to other objects.

Your public interface IPandaClass { } is exactly the same. I guess you forgot to mention that it has the GetHandler method or otherwise it would be completely meaningless.
Then we read:

This interface is implemented by a class or value type that provides a service to other objects.

This is the missing GetHandler method.

Generics vs strings

RegisterHandler(&quot;messages&quot;, Utilities.CreateInstanceOf&lt;MessageHandler&gt;());


Instead of hardcoding strings you could use generics and derive the name from the class name or just use the type as a key.

Dependency Injection
Do you really need all classes in one handler? Have you tried something like Autofac etc.?