|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Enum and FlagsAttributeI really need a FlagsAttribute for the enum as it will be use to trigger multiple choice Thanks for the help Function BuildEnum(ByVal EnumName As String, ByVal args As Hashtable) As Type Dim ad As AppDomain Dim an As New AssemblyName Dim ab As AssemblyBuilder Dim mb As ModuleBuilder Dim eb As EnumBuilder Dim t As Type Dim ie As IDictionaryEnumerator = args.GetEnumerator Try ad = AppDomain.CurrentDomain an.Name = EnumName ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.RunAndSave) mb = ab.DefineDynamicModule(EnumName, EnumName & ".dll") eb = mb.DefineEnum(EnumName, TypeAttributes.Public, GetType(Integer)) While ie.MoveNext eb.DefineLiteral(ie.Value, CInt(ie.Key)) End While t = eb.CreateType() Return t Catch ex As Exception ''do nothing Return Nothing Finally End Try End Function >How do I set a FlagsAttribute to a run time created enum Something like this:eb.SetCustomAttribute(New CustomAttributeBuilder(GetType(FlagsAttribute).GetConstructor(Type.EmptyTypes), New Object() {})) Mattias -- Mattias Sjögren [C# MVP] mattias @ mvps.org http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com Please reply only to the newsgroup. You'r my man thanks a lot :)
"Mattias Sjögren" <mattias.dont.want.spam@mvps.org> wrote in message CustomAttributeBuilder(GetType(FlagsAttribute).GetConstructor(Type.EmptyTypenews:%23hft5P7QGHA.5808@TK2MSFTNGP12.phx.gbl... > >How do I set a FlagsAttribute to a run time created enum > > Something like this: > > eb.SetCustomAttribute(New > s), Show quoteHide quote > New Object() {})) > > > Mattias > > -- > Mattias Sjögren [C# MVP] mattias @ mvps.org > http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com > Please reply only to the newsgroup.
Can't modify instance of a class from within the class!
WebBrowser Control Printing Garbage collection, Unmanaged code and SafeArrays Problem sending Report as EMail - wrong attach. name "untitled.txt" creating independant application vb 2005 express edition Regular Expression Question Fastest way to load jpg images ? Single event handler for menu How to.... Question..... Access digital camera |
|||||||||||||||||||||||