infra du badge paramêtre manquant
This commit is contained in:
@ -1,6 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using Microsoft.AspNet.Builder;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Yavsc.Models;
|
||||
using YavscLib;
|
||||
|
||||
namespace Yavsc
|
||||
{
|
||||
@ -10,15 +15,16 @@ namespace Yavsc
|
||||
/// Lists Available user profile classes,
|
||||
/// populated at startup, using reflexion.
|
||||
/// </summary>
|
||||
public static Dictionary<string,Type> ProfileTypes = new Dictionary<string,Type>() ;
|
||||
|
||||
public static List<Type> ProfileTypes = new List<Type>() ;
|
||||
public static List<PropertyInfo> UserSettings = new List<PropertyInfo> ();
|
||||
|
||||
/// <summary>
|
||||
/// Lists available command forms.
|
||||
/// This is hard coded.
|
||||
/// </summary>
|
||||
public static readonly string [] Forms = new string [] { "Profiles" , "HairCut" };
|
||||
|
||||
private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings)
|
||||
private void ConfigureWorkflow(IApplicationBuilder app, SiteSettings settings, ILogger logger)
|
||||
{
|
||||
System.AppDomain.CurrentDomain.ResourceResolve += OnYavscResourceResolve;
|
||||
|
||||
@ -26,10 +32,32 @@ namespace Yavsc
|
||||
foreach (var c in a.GetTypes()) {
|
||||
if (c.IsClass && !c.IsAbstract &&
|
||||
c.GetInterface("ISpecializationSettings")!=null) {
|
||||
ProfileTypes.Add(c.FullName,c);
|
||||
ProfileTypes.Add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (var propinfo in typeof(ApplicationDbContext).GetProperties()) {
|
||||
foreach (var attr in propinfo.CustomAttributes) {
|
||||
if (attr.AttributeType.FullName == "Yavsc.Attributes.ActivitySettingAttribute") {
|
||||
// bingo
|
||||
if (typeof(IQueryable<ISpecializationSettings>).IsAssignableFrom(propinfo.PropertyType))
|
||||
{
|
||||
logger.LogInformation($"Paramêtres utilisateur déclaré: {propinfo.Name}");
|
||||
UserSettings.Add(propinfo);
|
||||
|
||||
} else
|
||||
// Design time error
|
||||
{
|
||||
logger.LogCritical(
|
||||
$@"la propriété {propinfo.Name} du contexte de la
|
||||
base de donnée déclare être un refuge de paramêtre utilisateur
|
||||
du workflow, mais l'implemente pas l'interface IQueryable<ISpecializationSettings>,
|
||||
Elle est du type {propinfo.MemberType.GetType()}");
|
||||
throw new NotSupportedException("invalid ActivitySettingAttribute on property from dbcontext");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public static System.Reflection.Assembly OnYavscResourceResolve (object sender, ResolveEventArgs ev)
|
||||
{
|
||||
|
Reference in New Issue
Block a user