【发布时间】:2018-08-14 12:40:45
【问题描述】:
如何将一个类型添加到另一个ProvidedType,并指定该类型是一个静态类?
【问题讨论】:
标签: f# type-providers
如何将一个类型添加到另一个ProvidedType,并指定该类型是一个静态类?
【问题讨论】:
标签: f# type-providers
如何做到这一点并不是很明显,但您所要做的就是以TypeAttributes 的形式添加适当的元数据属性:
//create a providedtype
let myStaticType = ProvidedTypeDefinition("Tags", Some typeof<obj>, isErased = false)
//set the TypeAttributes on the type
myStaticType.SetAttributes (TypeAttributes.Public ||| TypeAttributes.Class ||| TypeAttributes.Sealed ||| TypeAttributes.Abstract)
//Add the static type to another type
parentType.AddMember myStaticType
静态类型只是具有抽象和密封TypeAttributes的类型
【讨论】: