open System.Collections.Generic
{new System.IDisposable with
open System.Runtime.CompilerServices
type CodeTypeDeclarationExtensions =
static member Start(ctd:CodeTypeDeclaration) name =
ctd.StartDirectives.Add(CodeRegionDirective(CodeRegionMode.Start,name)) |> ignore
static member End (ctd:CodeTypeDeclaration) name =
ctd.EndDirectives.Add(CodeRegionDirective(CodeRegionMode.End,name)) |> ignore
static member Regionize (ctd:CodeTypeDeclaration) name =
onDisposal (fun _ -> CodeTypeDeclarationExtensions.Start ctd name) (fun _ -> CodeTypeDeclarationExtensions.End ctd name)
static member AddFields (x:CodeTypeDeclaration) (kvpList:IDictionary<_,string>) f (cleaner:(string->string) option) =
for KeyValue(k,v) in kvpList do
let field = CodeMemberField(typedefof<string>,if cleaner.IsSome then cleaner.Value(v) else v)
x.Members.Add field |> ignore