您不能“从objectName创建通用T”,但是可以从类型构造通用方法。
我认为您正在寻找MethodInfo.MakeGenericMethod
用法,例如:
<template>
<div class="container">
<v-chip-group column active-class="primary--text">
<v-chip
v-for="tag in tags"
:key="tag"
class="ma-2"
outlined
x-small
color="blue"
text-color="blue"
>
{{ tag }}
</v-chip>
</v-chip-group>
</div>
</template>
<script>
export default {
name: 'Tags',props: {
tags: {
type: Array,default: () => ['Empty'],},}
</script>
然后致电,例如:
// somehow get fully qualified name from objectName
vat type = Type.GetType("fully qualified name");
var mi = _gateway.GetType().GetMethod("ReadByQueryAsync").MakeGenericMethod(type);
或使用expression trees构建lambda并将其缓存。
mi.Invoke(_gateway,null)
的示例:
Enumerable.First()
本文链接:https://www.f2er.com/2302200.html