diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs index 27a7ec0835858156a2b302bcb62ffe0e16de358f..3c50a79e814cf67eec17e7f7b1a65ce7583e4774 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/MMTConstants.cs @@ -222,15 +222,16 @@ public static class MMTConstants Product }, { MakeType, MakeTypeType }, - // needed? - //{ MakeTypeType, - // MakeTypeType }, + { MakeTypeType, + MakeTypeType }, }; public static readonly IReadOnlyDictionary<string, string> TypeOF_TO_HeterogenApplication = HeterogenApplication_TO_TypeOF.ReverseKeyVal(); public static readonly IReadOnlyDictionary<string, string> HomogenApplication_TO_TypeOF = new Dictionary<string, string> { { ListApplicant, ListType }, + { ListType, + ListType }, }; public static readonly IReadOnlyDictionary<string, string> TypeOF_TO_HomogenApplication = HomogenApplication_TO_TypeOF.ReverseKeyVal(); diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs index f30295569bbd7853486bc6fc60e39764576b4c31..24fd247ac025a506c60e135422cc6e45396e76af 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocToLambdaExpression.cs @@ -289,7 +289,9 @@ void ThrowArgumentException(ExpressionType expression_cast, int expected) int free_params = lambda_lambda.Parameters.Count() - lambda_applicant.Length; if (free_params <= 0) return Expression.Lambda( - Expression.Invoke(lambda_lambda, lambda_applicant[..^Math.Max(0, free_params)]), + Expression.Invoke( + lambda_lambda, + lambda_applicant.Select(app => app.Body).Take(lambda_lambda.Parameters.Count())), found_bound_params ); diff --git a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs index ec522d4c7c283fd50da983f19ae3a1d2dbf58daa..8f70b5958d198650662dbee5facb02fe3b3f24cc 100644 --- a/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs +++ b/Assets/Scripts/MMTServer/CommunicationProtocoll/SOMDocs.cs @@ -82,7 +82,10 @@ public static SOMDoc SOMDocType(Type type) type = typeof(Tuple); if (type.HasElementType) // pretend its a List - type = typeof(List<>); // Dictionary does not like Generics + type = typeof(List<>); + + if (type.IsGenericType) // Dictionary does not like Assembled Generics + type = type.GetGenericTypeDefinition(); if (FuncExtensions.IsFuncType(type, out _)) @@ -93,6 +96,13 @@ public static SOMDoc SOMDocType(Type type) ? new OMA(new OMS(uri), args) : new OMS(uri); + if (type.IsAnonymousType()) + return new OMA( + new OMS(MMTConstants.MakeTypeType), + type.GetFields() + .Select(mem => new OML_Member(mem.Name, SOMDocType(mem.FieldType), null)) + .ToArray()); + throw new NotImplementedException($"For Type {type}"); } @@ -554,7 +564,7 @@ protected internal override Type ToType(Type[] args, (string name, Type type)[] { if (FactRecorder.AllFacts.TryGetValue(uri, out Fact found)) return found.GetType(); - + if (MMTConstants.HeterogenApplication_TO_TypeOF.TryGetValue(uri, out string s_type)) { Type type = MMTConstants.OMS_TO_TYPE[s_type];