DarkRift.Server.PluginFactory.AddType C# (CSharp) Method

AddType() private method

Adds a type to the lookup.
private AddType ( Type plugin ) : void
plugin Type The plugin type to add.
return void
        internal void AddType(Type plugin)
        {
            if (!plugin.IsSubclassOf(typeof(PluginBase)))
                throw new ArgumentException($"The type supplied, '{plugin.Name}', was not a plugin. Ensure the type inherits from PluginBase.");

            if (plugin.IsAbstract)
                throw new ArgumentException($"The type supplied, '{plugin.Name}', was marked as abstract. Ensure the type is not abstract.");

            // Add if it has not already been added (and warn if two different types with the same name are added)
            if (!types.ContainsKey(plugin.Name))
                types.Add(plugin.Name, plugin);
            else if (types[plugin.Name] != plugin)
                logger.Error($"A plugin '{plugin.Name}' could not be added to the plugin factory as it was already present. This is likely because two plugins have the same name or the same DLL has been loaded multiple times. Consider renaming your plugins to avoid conflicts (note, namespaces are not considered) or update the plugin search paths configuration to avoid loading the same DLL multiple times.");
        }