diff --git a/src/ZirconiumPlugins/MongoDB/MongoDB.csproj b/src/ZirconiumPlugins/MongoDB/MongoDB.csproj
new file mode 100644
index 0000000..932a2a2
--- /dev/null
+++ b/src/ZirconiumPlugins/MongoDB/MongoDB.csproj
@@ -0,0 +1,16 @@
+
+
+
+ netcoreapp3.1
+
+
+
+
+ runtime
+
+
+
+
+
+
+
diff --git a/src/ZirconiumPlugins/MongoDB/Plugin.cs b/src/ZirconiumPlugins/MongoDB/Plugin.cs
new file mode 100644
index 0000000..203c28f
--- /dev/null
+++ b/src/ZirconiumPlugins/MongoDB/Plugin.cs
@@ -0,0 +1,58 @@
+using System.Collections.Immutable;
+using System.Collections.Generic;
+using Zirconium.Core.Plugins.Interfaces;
+using MongoDB.Driver;
+using Zirconium.Core.Logging;
+
+namespace MongoDBPlugin
+{
+ class Plugin : IPluginAPI
+ {
+ private IMongoDatabase _database;
+
+ public dynamic GetExportedAPI()
+ {
+ return _database;
+ }
+
+ public System.Type[] GetExportedTypes()
+ {
+ // var mongoCore = Assembly.Load("MongoDB.Driver.Core");
+ // var mongoBson = Assembly.Load("MongoDB.Bson");
+ return new System.Type[] {typeof(IMongoDatabase)};
+ }
+
+ public string GetPluginUniqueName()
+ {
+ return "MongoDB";
+ }
+
+ public void Initialize(IPluginHostAPI pluginHostAPI)
+ {
+ var settingsDynamic = pluginHostAPI.GetSettings(this);
+ var settings = (IImmutableDictionary) ((IDictionary)settingsDynamic).ToImmutableDictionary();
+
+ var host = (string) settings.GetValueOrDefault("Host");
+ var port = (int) settings.GetValueOrDefault("Port");
+ var user = (string) settings.GetValueOrDefault("User");
+ var password = (string) settings.GetValueOrDefault("Password");
+ var database = (string) settings.GetValueOrDefault("Database");
+
+ MongoClient client;
+ if (user == null && password == null)
+ {
+ client = new MongoClient($"mongodb://{host}:{port}");
+ }
+ else
+ {
+ client = new MongoClient($"mongodb://{user}:{password}@{host}:{port}");
+ }
+
+ var db = client.GetDatabase(database);
+ Log.Info("MongoDB is connected");
+ _database = db;
+ }
+
+ public void PreInitialize(IPluginManager pluginManager) { }
+ }
+}
diff --git a/src/ZirconiumPlugins/TestMongoDB/Plugin.cs b/src/ZirconiumPlugins/TestMongoDB/Plugin.cs
new file mode 100644
index 0000000..f6d90a0
--- /dev/null
+++ b/src/ZirconiumPlugins/TestMongoDB/Plugin.cs
@@ -0,0 +1,57 @@
+using Zirconium.Core.Plugins.Interfaces;
+using MongoDB.Driver;
+using Zirconium.Core.Logging;
+using System;
+
+namespace TestMongoDB
+{
+ class Plugin : IPluginAPI
+ {
+ private IMongoDatabase _database;
+
+ public dynamic GetExportedAPI()
+ {
+ return null;
+ }
+
+ public Type[] GetExportedTypes()
+ {
+ return null;
+ }
+
+ public string GetPluginUniqueName()
+ {
+ return "TestMongoDB";
+ }
+
+ public void Initialize(IPluginHostAPI pluginHostAPI)
+ {
+ var tm = new TestModel();
+ tm.ABC = "qweqowie";
+ _database.GetCollection("test_model").InsertOne(tm);
+ }
+
+ public void PreInitialize(IPluginManager pluginManager)
+ {
+ var db = pluginManager.Depends(this, "MongoDB");
+ var receivedType = db.GetType();
+ Log.Debug(db.GetType().FullName);
+ Log.Debug(db.GetType().AssemblyQualifiedName);
+ foreach (Type i in db.GetType().GetInterfaces()) {
+ Log.Debug("DB object interface: " + i.AssemblyQualifiedName);
+ }
+ Log.Debug("Type info in current assembly context:");
+ var mongoDBType = typeof(IMongoDatabase);
+ Log.Debug(mongoDBType.FullName);
+ Log.Debug(mongoDBType.AssemblyQualifiedName);
+ Log.Debug(new Uri(mongoDBType.Module.Assembly.CodeBase).LocalPath);
+ Log.Debug($"Casting compatibility: {mongoDBType.IsAssignableFrom(db.GetType())}");
+ _database = (IMongoDatabase) db;
+ }
+ }
+
+ class TestModel
+ {
+ public string ABC { get; set; }
+ }
+}
diff --git a/src/ZirconiumPlugins/TestMongoDB/TestMongoDB.csproj b/src/ZirconiumPlugins/TestMongoDB/TestMongoDB.csproj
new file mode 100644
index 0000000..70eb03f
--- /dev/null
+++ b/src/ZirconiumPlugins/TestMongoDB/TestMongoDB.csproj
@@ -0,0 +1,15 @@
+
+
+
+ netcoreapp3.1
+
+
+
+
+ runtime
+
+
+
+
+
+