public Maybe<Type> TryLookupActualType(LogicalType logicalType) { var result = _logicalToActualMappings.TryGetValue(logicalType); if(!result.HasValue && !logicalType.IsOpenType) { var openActualType = _logicalToActualMappings.TryGetValue(logicalType.GetOpenType()); if (!openActualType.HasValue) return Maybe.NoValue; var typeArguments = logicalType.TypeArguments .Select(x => TryLookupActualType(x)) .Squash() .ToArray(); var actualType = openActualType.Value; if (typeArguments.Length == actualType.GetGenericArguments().Length) return actualType.MakeGenericType(typeArguments).ToMaybe(); } return result; }
public void GetOpenType() { var logicalType = new LogicalType("tst", "Result", new[] { new LogicalType("sys", "Int32"), new LogicalType("sys", "String") }, Maybe.NoValue); var openLogicalType = logicalType.GetOpenType(); openLogicalType.Equals(LogicalType.Parse("tst:Result`2")).Should().BeTrue(); }