Skip to content

Commit

Permalink
Merge branch 'dev' of https://github.com/EAVFW/EAVFramework into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
pksorensen committed Aug 25, 2024
2 parents a84f5e2 + ef61ef8 commit 9ba934a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -528,13 +528,13 @@ public static IResourceBuilder<EAVFWModelProjectResource> FromBackup(this IResou
public static IResourceBuilder<EAVFWModelProjectResource> PublishTo(
this IResourceBuilder<EAVFWModelProjectResource> builder,
IResourceBuilder<SqlServerDatabaseResource> target,
string administratorEmail, Guid initialAdministratorUserId, string Username, string schema = "dbo"
string administratorEmail, Guid initialAdministratorUserId, string Username, string schema = "dbo", string systemUsersTableName = "SystemUsers"
)
{
builder.ApplicationBuilder.Services.TryAddLifecycleHook<PublishEAVFWProjectLifecycleHook>();
builder.WithAnnotation(new TargetDatabaseResourceAnnotation(target.Resource.Name, target.Resource)
{
InitialEmail = administratorEmail, InitialIdentity = initialAdministratorUserId, Schema = schema, InitialUsername = Username, UserPrincipalName = Username.Replace(" ","")
InitialEmail = administratorEmail, InitialIdentity = initialAdministratorUserId, SystemUsersTableName = systemUsersTableName, Schema = schema, InitialUsername = Username, UserPrincipalName = Username.Replace(" ","")
}, ResourceAnnotationMutationBehavior.Replace);
return builder;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ private static async Task DoMigrationAsync(string modelProjectPath, TargetDataba
var variablegenerator = new SQLClientParameterGenerator();
var migrator = new SQLMigrationGenerator(variablegenerator, new ManifestPermissionGenerator(variablegenerator));

var sqls = await migrator.GenerateSQL(Path.GetDirectoryName(modelProjectPath), true, "SystemUsers",
var sqls = await migrator.GenerateSQL(Path.GetDirectoryName(modelProjectPath), true, targetDatabaseResourceAnnotation.SystemUsersTableName ?? "SystemUsers",
o =>
{
o.UseNetTopologySuite();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public record TargetDatabaseResourceAnnotation(string TargetDatabaseResourceName
public string InitialEmail { get; set; }
public string UserPrincipalName { get; set; }
public string InitialUsername { get; set; }
public string SystemUsersTableName{get;set;} = "SystemUsers";
public string InitialSystemSecurityGroupId { get; set; } = "1b714972-8d0a-4feb-b166-08d93c6ae328";
}
public record CreateSigninUrlAnnotation(IResource Target, IResource Project) : IResourceAnnotation
Expand Down
6 changes: 3 additions & 3 deletions src/Configuration/GenericTypeExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public static object GetDynamicService<TContext>(this IServiceProvider servicePr

var ctx = serviceProvider.GetRequiredService<TContext>();

var targetType = ResoveType<TContext>(t,ctx);
var targetType = ResoveType<TContext>(ctx,t);

return ActivatorUtilities.CreateInstance(serviceProvider, targetType);

Expand All @@ -24,7 +24,7 @@ public static object GetDynamicService<TContext>(this IServiceProvider servicePr

}

private static Type ResoveType<TContext>(Type t, TContext ctx) where TContext : DynamicContext
public static Type ResoveType<TContext>( this TContext ctx, Type t) where TContext : DynamicContext
{


Expand Down Expand Up @@ -143,7 +143,7 @@ private static Type ResolveGenericArgument<TContext>(Type t, TContext ctx, Type

var targetServiceType = constraints.First();

return ResoveType(targetServiceType.IsGenericType ? targetServiceType.GetGenericTypeDefinition() : targetServiceType, ctx);
return ResoveType(ctx,targetServiceType.IsGenericType ? targetServiceType.GetGenericTypeDefinition() : targetServiceType);
}

public static Type ResolveGenericArguments<TContext,TModel>(this Type t) where TContext : DynamicContext
Expand Down
4 changes: 2 additions & 2 deletions src/Configuration/IEAVFrameworkBuilderExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EAVFramework.Infrastructure.HealthChecks;
using EAVFramework.Infrastructure.HealthChecks;
using EAVFramework.Plugins;
using Microsoft.Extensions.DependencyInjection;
using System.Linq;
Expand All @@ -13,7 +13,7 @@ public static IEAVFrameworkBuilder WithPluginsDiscovery<T>(this IEAVFrameworkBui
var autoPlugins = typeof(T).Assembly.GetTypes().Where(type => type.GetCustomAttributes<PluginRegistrationAttribute>().Any())
.ToArray();

foreach (var plugin in autoPlugins)
foreach (var plugin in autoPlugins.Where(t=>!t.ContainsGenericParameters))
{
builder.AddPlugin(plugin);
}
Expand Down
8 changes: 7 additions & 1 deletion src/Shared/V2/DefaultEmitPropertyService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using EAVFW.Extensions.Manifest.SDK;
using EAVFW.Extensions.Manifest.SDK;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -406,13 +406,16 @@ private Type GetTypeBuilderFromConstraint( Type constraint, DynamicTableBuilder
return Nullable.GetUnderlyingType(prop.DTOPropertyType ?? prop.PropertyType) ?? prop.DTOPropertyType ?? prop.PropertyType;

}


}catch(Exception ex)
{
throw new InvalidOperationException($"Failed to get builder from constraint: {constraint.Name}",ex);
//throw new InvalidOperationException($"Failed to get builder from constraint: {constraint.Name} -" +
// $" {string.Join(",", constraint.GetGenericParameterConstraints().Select(c=>$"{c.Name}<{string.Join(",", c.GetCustomAttributes<EntityInterfaceAttribute>().Select(cc=>cc.EntityKey))}>" ))}", ex);
}

// if (constraint.GetGenericParameterConstraints() is Type[] array && array.Length == 2 && array.Any(a=>a==))

//if (!constraint.GetGenericParameterConstraints().Any())
//{
Expand Down Expand Up @@ -467,7 +470,10 @@ private Type GetTypeBuilderFromConstraint( Type constraint, DynamicTableBuilder
//}
// File.AppendAllLines("test1.txt", new[] { $"Inteface type: {constraint.DeclaringType.FullName} is Generic<{string.Join(",", constraint.GetGenericParameterConstraints().Select(p => p.Name))}>" });
var constraints = constraint.GetGenericParameterConstraints().ToArray();
if (constraints.Length>1)
{

}

var @interface = constraint.GetGenericParameterConstraints().Single();

Expand Down

0 comments on commit 9ba934a

Please sign in to comment.