X Tutup
<#@ template hostspecific="false" language="C#" #> <#@ output extension=".cs" #> <#@ assembly name="System.Core" #> <#@ assembly name="System.Linq" #> <#@ import namespace="System.Reflection" #> <#@ import namespace="System.Linq" #> <#@ import namespace="System.IO" #> namespace Python.Runtime { partial class Runtime { <# string FormatType(Type type) { if (type == typeof(void)) return "void"; if (type.IsByRef) return $"ref {type.GetElementType().ToString()}"; return type.ToString(); } var path = $"{Directory.GetCurrentDirectory()}/Python.Runtime.Interfaces/bin/Debug/netstandard2.0/Python.Runtime.Interfaces.dll"; var assembly = Assembly.LoadFile(path); var type = assembly.GetType("Python.Runtime.Interfaces.ILibPython"); const BindingFlags flags = BindingFlags.Public | BindingFlags.FlattenHierarchy | BindingFlags.Instance; var methods = type.GetMethods(flags); foreach (var method in methods) { #> internal static <#= FormatType(method.ReturnParameter.ParameterType) #> <#= method.Name #>(<#= string.Join(", ", method.GetParameters().Select(x => $"{FormatType(x.ParameterType)} {x.Name}")) #>) => LibPython.<#= method.Name #>(<#= string.Join(", ", method.GetParameters().Select(x => (x.ParameterType.IsByRef ? "ref " : "") + x.Name)) #>); <# } #> } }
X Tutup