/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="filter"></param> public void GenerateEnums(RegistryContext ctx, string path, EnumerantFilterDelegate filter) { if (path == null) { throw new ArgumentNullException("path"); } List <Enumerant> enumerants = _Registry.Enumerants; if ((filter != null) && (enumerants.FindIndex(delegate(Enumerant item) { return(filter(item)); }) < 0)) { return; } Console.WriteLine("Generate registry enums to {0}.", path); using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) { GenerateLicensePreamble(sw); sw.WriteLine("using System;"); sw.WriteLine(); sw.WriteLine("namespace {0}", Namespace); sw.WriteLine("{"); sw.Indent(); sw.WriteLine("public partial class {0}", ctx.Class); sw.WriteLine("{"); sw.Indent(); foreach (Enumerant enumerant in _Registry.Enumerants) { if ((filter != null) && (filter(enumerant) == false)) { continue; } enumerant.GenerateSource(sw, ctx); sw.WriteLine(); } sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.WriteLine(); sw.WriteLine("}"); } }
/// <summary> /// /// </summary> /// <param name="path"></param> /// <param name="filter"></param> public void GenerateEnums(RegistryContext ctx, string path, EnumerantFilterDelegate filter) { if (path == null) throw new ArgumentNullException("path"); List<Enumerant> enumerants = mRegistry.Enumerants; if ((filter != null) && (enumerants.FindIndex(delegate(Enumerant item) { return (filter(item)); }) < 0)) return; Console.WriteLine("Generate registry enums to {0}.", path); using (SourceStreamWriter sw = new SourceStreamWriter(path, false)) { GenerateLicensePreamble(sw); sw.WriteLine(); sw.WriteLine("using System;"); sw.WriteLine(); sw.WriteLine("namespace OpenGL"); sw.WriteLine("{"); sw.Indent(); sw.WriteLine("public partial class {0}", ctx.Class); sw.WriteLine("{"); sw.Indent(); foreach (Enumerant enumerant in mRegistry.Enumerants) { if ((filter != null) && (filter(enumerant) == false)) continue; enumerant.GenerateSource(sw, ctx); sw.WriteLine(); } sw.Unindent(); sw.WriteLine("}"); sw.Unindent(); sw.WriteLine(); sw.WriteLine("}"); } }