/// <summary> /// Initializes a new instance of the <see cref="GeneratedTableCode"/> class. /// </summary> /// <param name="table">The table that the code was generated for.</param> /// <param name="className">The name of the class or interface that was generated.</param> /// <param name="code">The generated code.</param> /// <param name="codeType">The type of code that this is for.</param> public GeneratedTableCode(string table, string className, string code, GeneratedCodeType codeType) { _table = table; _className = className; _code = code; _codeType = codeType; }
/// <summary> /// Initializes a new instance of the <see cref="GeneratedTableCode"/> class. /// </summary> /// <param name="table">The table that the code was generated for.</param> /// <param name="className">The name of the class or interface that was generated.</param> /// <param name="code">The generated code.</param> /// <param name="codeType">The type of code that this is for.</param> public GeneratedTableCode(string table, string className, string code, GeneratedCodeType codeType) { _table = table; _className = className; _code = code; _codeType = codeType; }
static public bool IsEditorOnly(this GeneratedCodeType item) { if (item.IsRuntime() == false) { return(true); } return(false); }
static public bool IsLeaf(this GeneratedCodeType item) { if (item.IsDefinition() == false) { return(true); } return(false); }
static public string GetDirectory(this GeneratedCodeType item) { switch (item) { case GeneratedCodeType.RuntimeDefinition: return(Project.GetGeneratedDirectory()); case GeneratedCodeType.RuntimeLeaf: return(Project.GetGeneratedLeafDirectory()); case GeneratedCodeType.EditorOnlyDefinition: return(Project.GetEditorGeneratedDirectory()); case GeneratedCodeType.EditorOnlyLeaf: return(Project.GetEditorGeneratedLeafDirectory()); } throw new UnaccountedBranchException("item", item); }
static public bool IsRuntime(this GeneratedCodeType item) { switch (item) { case GeneratedCodeType.RuntimeDefinition: return(true); case GeneratedCodeType.RuntimeLeaf: return(true); case GeneratedCodeType.EditorOnlyDefinition: return(false); case GeneratedCodeType.EditorOnlyLeaf: return(false); } throw new UnaccountedBranchException("item", item); }
static public void GenerateStaticClass(string class_name, Process <CSTextDocumentBuilder> process, GeneratedCodeType type) { GenerateCode(class_name, delegate(CSTextDocumentBuilder builder) { CSTextDocumentWriter writer = builder.CreateWriterWithVariablePairs( "CLASS", class_name.StyleAsClassName() ); writer.Write("static public class ?CLASS", delegate() { process(builder); }); }, type); }
static public void GenerateCode(string base_filename, Process <CSTextDocumentBuilder> process, GeneratedCodeType type) { CSTextDocument document = new CSTextDocument(new CSHeader_SimpleStatement()); CSTextDocumentBuilder builder = document.CreateCSTextBuilder(); CSTextDocumentWriter writer = builder.CreateWriterWithVariablePairs(); writer.Write("using System;"); writer.Write("using System.Collections;"); writer.Write("using System.Collections.Generic;"); writer.Write("using UnityEngine;"); writer.Write("#if UNITY_EDITOR"); writer.Write("using UnityEditor;"); writer.Write("using Crunchy.SandwichBag;"); writer.Write("#endif"); writer.Write("using Crunchy.Dough;"); writer.Write("using Crunchy.Salt;"); writer.Write("using Crunchy.Noodle;"); writer.Write("using Crunchy.Bread;"); writer.Write("using Crunchy.Sandwich;"); process(builder); if (document.RenderDocument().SaveChanges(type.GetDirectory(), base_filename + ".cs", true)) { REGENERATION_COUNT++; } }