public static string GetCppWinRTType(MrType t) { var primitiveTypes = new Dictionary <string, string>() { { "System.String", "winrt::hstring" }, { "System.Boolean", "bool" }, { "System.Int32", "int32_t" }, { "System.Int64", "int64_t" }, { "System.Double", "double" }, { "System.Single", "float" }, { "System.Uri", "winrt::Windows::Foundation::Uri" }, { "System.Object", "winrt::Windows::Foundation::IInspectable" }, }; if (t.GetFullName() == $"{XamlNames.XamlNamespace}.Controls.Maps.MapStyle") { // MapStyle has a bug where it doesn't support coercion from int } else if (t.IsEnum) { return("int32_t"); } else if (t.GetFullName() == "System.Nullable`1") { return(GetCppWinRTType(t.GetGenericTypeParameters().First())); } if (primitiveTypes.ContainsKey(t.GetFullName())) { return(primitiveTypes[t.GetFullName()]); } return($"winrt::{t.GetFullName().Replace(".", "::")}"); }
private static string MapManagedTypeToWinRtType(MrType t) { var map = new Dictionary <string, string> { { typeof(Object).FullName, "Windows.Foundation.IInspectable" }, { "System.Collections.Generic.IList`1", "Windows.Foundation.Collections.IVector`1" }, { "System.Collections.Generic.IReadOnlyList`1", "Windows.Foundation.Collections.IVectorView`1" }, { "System.Collections.Generic.IDictionary`2", "Windows.Foundation.Collections.IMap`2" }, { "System.Collections.Generic.IReadOnlyDictionary`2", "Windows.Foundation.Collections.IMapView`2" }, }; if (map.ContainsKey(t.GetFullName())) { return(map[t.GetFullName()]); } if (t.GetNamespace() == "System") { return(t.GetName()); } else { return(t.GetFullName()); } }
private static string GetSimpleTypeName(MrType t, ImmutableArray <MrType> gargs, ImmutableArray <MrType> gparams) { string name; if (t.IsTypeCode) { name = t.TypeCode.ToString(); } else if (t.GetNamespace() == "System") { name = MapManagedTypeToWinRtType(t); } else if (!gargs.IsEmpty || !gparams.IsEmpty) { name = MapManagedTypeToWinRtType(t); name = name.Substring(0, name.IndexOf('`')); } else { name = t.GetFullName(); } return(name); }