Merge branch 'oqtane:dev' into dev
This commit is contained in:
		| @ -1,6 +1,7 @@ | ||||
| using System.Collections.Generic; | ||||
| using System.IO; | ||||
| using System.Linq; | ||||
| using System.Runtime.Loader; | ||||
| using Oqtane.Modules; | ||||
| using Oqtane.Services; | ||||
| using Oqtane.Shared; | ||||
| @ -72,6 +73,7 @@ namespace System.Reflection | ||||
|         { | ||||
|             return appDomain.GetAssemblies().Where(a => a.IsOqtaneAssembly()); | ||||
|         } | ||||
|  | ||||
|         public static IEnumerable<Assembly> GetOqtaneClientAssemblies(this AppDomain appDomain) | ||||
|         { | ||||
|             return appDomain.GetOqtaneAssemblies() | ||||
| @ -80,7 +82,7 @@ namespace System.Reflection | ||||
|         } | ||||
|  | ||||
|         /// <summary> | ||||
|         /// Checks if type should be ignored by oqtane dynamic loader  | ||||
|         /// Checks if type should be ignored by oqtane dynamic loader | ||||
|         /// </summary> | ||||
|         /// <param name="type">Checked type</param> | ||||
|         /// <returns></returns> | ||||
| @ -88,5 +90,44 @@ namespace System.Reflection | ||||
|         { | ||||
|             return Attribute.IsDefined(type, typeof(OqtaneIgnoreAttribute)) || type.IsAbstract || type.IsGenericType; | ||||
|         } | ||||
|  | ||||
|         public static void LoadOqtaneAssembly(this AssemblyLoadContext loadContext, FileInfo dll) | ||||
|         { | ||||
|             AssemblyName assemblyName = null; | ||||
|             try | ||||
|             { | ||||
|                 assemblyName = AssemblyName.GetAssemblyName(dll.FullName); | ||||
|             } | ||||
|             catch | ||||
|             { | ||||
|                 Console.WriteLine($"Not Assembly : {dll.Name}"); | ||||
|             } | ||||
|  | ||||
|             loadContext.LoadOqtaneAssembly(dll, assemblyName); | ||||
|         } | ||||
|  | ||||
|         public static void LoadOqtaneAssembly(this AssemblyLoadContext loadContext, FileInfo dll, AssemblyName assemblyName) | ||||
|         { | ||||
|             try | ||||
|             { | ||||
|                 var pdb = Path.ChangeExtension(dll.FullName, ".pdb"); | ||||
|                 Assembly assembly = null; | ||||
|  | ||||
|                 // load assembly ( and symbols ) from stream to prevent locking files ( as long as dependencies are in /bin they will load as well ) | ||||
|                 if (File.Exists(pdb)) | ||||
|                 { | ||||
|                     assembly = loadContext.LoadFromStream(new MemoryStream(File.ReadAllBytes(dll.FullName)), new MemoryStream(File.ReadAllBytes(pdb))); | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     assembly = loadContext.LoadFromStream(new MemoryStream(File.ReadAllBytes(dll.FullName))); | ||||
|                 } | ||||
|                 Console.WriteLine($"Loaded : {assemblyName}"); | ||||
|             } | ||||
|             catch (Exception e) | ||||
|             { | ||||
|                 Console.WriteLine($"Failed : {assemblyName}\n{e}"); | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,34 +0,0 @@ | ||||
| using System.Collections.Generic; | ||||
| using System.Data; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||||
| using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; | ||||
| using Oqtane.Models; | ||||
|  | ||||
| namespace Oqtane.Interfaces | ||||
| { | ||||
|     public interface IOqtaneDatabase | ||||
|     { | ||||
|         public string FriendlyName { get; } | ||||
|  | ||||
|         public string Name { get; } | ||||
|  | ||||
|         public string Provider { get; } | ||||
|  | ||||
|         public string TypeName { get; } | ||||
|  | ||||
|         public OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name); | ||||
|  | ||||
|         public string ConcatenateSql(params string[] values); | ||||
|  | ||||
|         public int ExecuteNonQuery(string connectionString, string query); | ||||
|  | ||||
|         public IDataReader ExecuteReader(string connectionString, string query); | ||||
|  | ||||
|         public string RewriteName(string name); | ||||
|  | ||||
|         public void UpdateIdentityStoreTableNames(ModelBuilder builder); | ||||
|  | ||||
|         public DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString); | ||||
|     } | ||||
| } | ||||
| @ -9,5 +9,7 @@ namespace Oqtane.Models | ||||
|         public string ControlType { get; set; } | ||||
|  | ||||
|         public string DBType { get; set; } | ||||
|  | ||||
|         public string Package { get; set; } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -1,29 +1,11 @@ | ||||
| using System; | ||||
| using Oqtane.Interfaces; | ||||
|  | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public class InstallConfig | ||||
|     { | ||||
|         private IOqtaneDatabase _database; | ||||
|  | ||||
|         public string ConnectionString { get; set; } | ||||
|         public string DatabaseType { get; set; } | ||||
|  | ||||
|         public IOqtaneDatabase Database | ||||
|         { | ||||
|             get | ||||
|             { | ||||
|                 if (_database == null) | ||||
|                 { | ||||
|                     var type = Type.GetType(DatabaseType); | ||||
|                     _database = Activator.CreateInstance(type) as IOqtaneDatabase; | ||||
|                 } | ||||
|  | ||||
|                 return _database; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         public string DatabasePackage { get; set; } | ||||
|         public string Aliases { get; set; } | ||||
|         public string TenantName { get; set; } | ||||
|         public bool IsNewTenant { get; set; } | ||||
|  | ||||
| @ -1,61 +0,0 @@ | ||||
| using System; | ||||
| using System.Collections.Generic; | ||||
| using System.Data; | ||||
| using Microsoft.EntityFrameworkCore; | ||||
| using Microsoft.EntityFrameworkCore.Migrations.Operations; | ||||
| using Microsoft.EntityFrameworkCore.Migrations.Operations.Builders; | ||||
| using Oqtane.Interfaces; | ||||
| using Oqtane.Models; | ||||
|  | ||||
| namespace Oqtane.Shared | ||||
| { | ||||
|     public abstract class OqtaneDatabaseBase : IOqtaneDatabase | ||||
|     { | ||||
|         protected OqtaneDatabaseBase(string name, string friendlyName) | ||||
|         { | ||||
|             Name = name; | ||||
|             FriendlyName = friendlyName; | ||||
|         } | ||||
|  | ||||
|         public  string FriendlyName { get; } | ||||
|  | ||||
|         public string Name { get; } | ||||
|  | ||||
|         public abstract string Provider { get; } | ||||
|  | ||||
|         public abstract string TypeName { get; } | ||||
|  | ||||
|         public abstract OperationBuilder<AddColumnOperation> AddAutoIncrementColumn(ColumnsBuilder table, string name); | ||||
|  | ||||
|         public virtual string ConcatenateSql(params string[] values) | ||||
|         { | ||||
|             var returnValue = String.Empty; | ||||
|             for (var i = 0; i < values.Length; i++) | ||||
|             { | ||||
|                 if (i > 0) | ||||
|                 { | ||||
|                     returnValue += " + "; | ||||
|                 } | ||||
|                 returnValue += values[i]; | ||||
|             } | ||||
|  | ||||
|             return returnValue; | ||||
|         } | ||||
|  | ||||
|         public abstract int ExecuteNonQuery(string connectionString, string query); | ||||
|  | ||||
|         public abstract IDataReader ExecuteReader(string connectionString, string query); | ||||
|  | ||||
|         public virtual string RewriteName(string name) | ||||
|         { | ||||
|             return name; | ||||
|         } | ||||
|  | ||||
|         public virtual void UpdateIdentityStoreTableNames(ModelBuilder builder) | ||||
|         { | ||||
|  | ||||
|         } | ||||
|  | ||||
|         public abstract DbContextOptionsBuilder UseDatabase(DbContextOptionsBuilder optionsBuilder, string connectionString); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user
	 iJungleboy
					iJungleboy