コード例 #1
0
    private void GenerateScript()
    {
        StringBuilder sb = new StringBuilder();

        sb.Append(File.ReadAllText(Config.ScriptableTemplatePath));

        // Fill Entity content in template
        // Fill Field names in attribute
        sb.Replace(TemplateSymbol.k_FIELDNAMES, GetFieldNameInAttr().ToString());
        // Fill Field types in attribute
        sb.Replace(TemplateSymbol.k_FIELDTYPES, GetFieldTypeInAttr().ToString());
        // Fill Entity names
        sb.Replace(TemplateSymbol.k_ENTITYNAME, EntityName);
        // Fill Entity Body
        sb.Replace(TemplateSymbol.k_FIELDS, GetEntityBody().ToString());
        // Fill extra definitions
        sb.Replace(TemplateSymbol.k_ENUMDEF, GetEnumScript().ToString());

        // Fill table content in template
        var excelPath = FilePath;
        var assetName = EntityName.Replace(Config.EntityPrefix, Config.ScriptablePrefix);

        sb.Replace(TemplateSymbol.k_EXCELPATH, excelPath);
        sb.Replace(TemplateSymbol.k_ASSETSCRIPTNAME, assetName);

        // Write to disk
        if (!Directory.Exists(Config.TableScriptablePath))
        {
            Directory.CreateDirectory(Config.TableScriptablePath);
        }
        var path = Path.Combine(
            Config.TableScriptablePath,
            assetName + ".cs"
            );

        File.WriteAllText(path, sb.ToString());
        Directory.SetLastWriteTime(path, DateTime.Now);
    }
コード例 #2
0
 public string GetEntityNameFromTombstone()
 {
     return(EntityName.Replace(EntityTombstoneAttribute.DefaultTableSuffixe, string.Empty));
 }