Skip to content

Commit

Permalink
Merge pull request #10 from EAVFW/dev
Browse files Browse the repository at this point in the history
Release latest
  • Loading branch information
pksorensen authored Oct 2, 2023
2 parents ef97979 + aa9053f commit 2f3a30e
Show file tree
Hide file tree
Showing 33 changed files with 789 additions and 439 deletions.
6 changes: 5 additions & 1 deletion generators/EAVFramework.SourceGenerator/DTOGenerators.cs
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,11 @@ Type CreateTypeForReferencedBaseClass(INamedTypeSymbol baseType)
}
catch (Exception ex)

Check warning on line 869 in generators/EAVFramework.SourceGenerator/DTOGenerators.cs

View workflow job for this annotation

GitHub Actions / Releasing

The variable 'ex' is declared but never used
{
File.AppendAllLines("err.txt", new[] { ex.ToString() });
throw;
//try
//{
// File.AppendAllLines("err.txt", new[] { ex.ToString() });
//}
// context.ReportDiagnostic(Diagnostic.Create(new DiagnosticDescriptor("100", "test2", ex.StackTrace.ToString(), "", DiagnosticSeverity.Info, true), null));
// context.ReportDiagnostic(Diagnostic.Create(new DiagnosticDescriptor("101", "test2", ex.ToString().Replace("\n", " "), "", DiagnosticSeverity.Info, true), null));

Expand Down
13 changes: 7 additions & 6 deletions src/Configuration/EAVFrameworkBuilderExtensionsCore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
using System.Linq.Expressions;
using System.Linq;
using EAVFramework.Shared;
using EAVFramework.Endpoints.Query.OData;

namespace Microsoft.Extensions.DependencyInjection
{
Expand Down Expand Up @@ -69,16 +70,16 @@ public static Type ResolveGenericArguments<TContext,TModel>(this Type t) where T
if(constraints.Any(tta => tta == typeof(IConvertible)))
{
//enums
var constraintMapping = t.GetCustomAttributes<ConstraintMappingAttribute>().FirstOrDefault(c => c.ConstraintName == ta.Name)
var constraintMapping = t.GetCustomAttributes<ConstraintMappingAttribute>().SingleOrDefault(c => c.ConstraintName == ta.Name)
?? throw new InvalidOperationException($"No ConstraintMappingAttribute set for the Contraints {ta.Name} on {t.Name}");
var entirtyType = typeof(TModel).Assembly.GetTypes().FirstOrDefault(t =>
var entirtyType = typeof(TModel).Assembly.GetTypes().SingleOrDefault(t =>
t.GetCustomAttribute<EntityDTOAttribute>() is EntityDTOAttribute &&
t.GetCustomAttribute<EntityAttribute>() is EntityAttribute attr && attr.EntityKey == constraintMapping.EntityKey);
var propertyType = entirtyType.GetProperties().FirstOrDefault(c =>
var propertyType = entirtyType.GetProperties().Single(c =>
c.GetCustomAttribute<EntityFieldAttribute>() is EntityFieldAttribute field && field.AttributeKey == constraintMapping.AttributeKey);
return Nullable.GetUnderlyingType(propertyType.PropertyType) ?? propertyType.PropertyType;
Expand All @@ -93,12 +94,12 @@ public static Type ResolveGenericArguments<TContext,TModel>(this Type t) where T
if (@interface.IsGenericType)
{
return typeof(TModel).Assembly.GetTypes().Where(t => t.GetCustomAttribute<EntityDTOAttribute>() != null &&
t.GetInterfaces().Any(c => c.IsGenericType && c.GetGenericTypeDefinition() == @interface.GetGenericTypeDefinition())).FirstOrDefault();
t.GetInterfaces().Any(c => c.IsGenericType && c.GetGenericTypeDefinition() == @interface.GetGenericTypeDefinition())).Single();
}
return typeof(TModel).Assembly.GetTypes().Where(t => t.GetCustomAttribute<EntityDTOAttribute>() != null &&
t.GetInterfaces().Any(c => c == @interface)).FirstOrDefault();
t.GetInterfaces().Any(c => c == @interface)).Single();
}
throw new InvalidOperationException($"Cant find constraint for {ta.Name} on {t.Name}" );
Expand Down Expand Up @@ -248,7 +249,7 @@ public static IEAVFrameworkBuilder AddCookieAuthentication(this IEAVFrameworkBui
.AddCookie(Constants.DefaultCookieAuthenticationScheme, options =>
{
options.Events.OnRedirectToAccessDenied = ReplaceRedirector(HttpStatusCode.Forbidden, options.Events.OnRedirectToAccessDenied);
options.Events.OnRedirectToLogin = ReplaceRedirector(HttpStatusCode.Unauthorized, options.Events.OnRedirectToLogin);
Expand Down
19 changes: 19 additions & 0 deletions src/ConstantRuntimeType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using EAVFramework.Endpoints.Query.OData;

namespace EAVFramework
{
public class ConstantRuntimeType : IODataRuntimeType
{
private string logicalName;

public ConstantRuntimeType(string logicalName)
{
this.logicalName=logicalName;
}

public string GetDataType(object data)
{
return logicalName;
}
}
}
23 changes: 23 additions & 0 deletions src/DefaultFormContextFeature.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Options;
using Newtonsoft.Json.Linq;
using System;
using System.Linq;
using System.Threading.Tasks;

namespace EAVFramework
{
public class DefaultFormContextFeature<TDynamicContext> :IFormContextFeature<DynamicContext> where TDynamicContext : DynamicContext
{
private readonly IOptions<DynamicContextOptions> options;

public DefaultFormContextFeature(IOptions<DynamicContextOptions> options)
{
this.options = options ?? throw new ArgumentNullException(nameof(options));
}

public ValueTask<JToken> GetManifestAsync()
{
return new ValueTask<JToken>(options.Value.Manifests.First());
}
}
}
Loading

0 comments on commit 2f3a30e

Please sign in to comment.