feat : 支持无命名空间

main
Carson Lin 2022-09-10 11:10:23 +08:00
parent ad4acf337f
commit d9013167b8
7 changed files with 41 additions and 21 deletions

View File

@ -312,5 +312,27 @@ namespace Luban.Job.Cfg.Utils
{ {
return type.Apply(CsEditorInitValueVisitor.Ins); return type.Apply(CsEditorInitValueVisitor.Ins);
} }
public static string CsStartNameSpaceGrace(string np)
{
if (string.IsNullOrEmpty(np))
{
return string.Empty;
}
else
{
return $"namespace {np}\r\n{{";
}
}
public static string CsEndNameSpaceGrace(string np)
{
if (string.IsNullOrEmpty(np))
{
return string.Empty;
}
else
{
return "}";
}
}
} }
} }

View File

@ -5,8 +5,8 @@
items = x.items items = x.items
~}} ~}}
namespace {{namespace_with_top_module}}
{ {{cs_start_name_space_grace x.namespace_with_top_module}}
{{~if comment != '' ~}} {{~if comment != '' ~}}
/// <summary> /// <summary>
/// {{comment | html.escape}} /// {{comment | html.escape}}
@ -26,4 +26,5 @@ namespace {{namespace_with_top_module}}
{{item.name}} = {{item.value}}, {{item.name}} = {{item.value}},
{{~end~}} {{~end~}}
} }
}
{{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -7,10 +7,8 @@ using System.Collections.Generic;
hierarchy_export_fields = x.hierarchy_export_fields hierarchy_export_fields = x.hierarchy_export_fields
}} }}
{{cs_start_name_space_grace x.namespace_with_top_module}}
namespace {{x.namespace_with_top_module}} //ĂüĂűżŐźä{{x.namespace_with_top_module}}
{
{{~if x.comment != '' ~}} {{~if x.comment != '' ~}}
/// <summary> /// <summary>
/// {{x.escape_comment}} /// {{x.escape_comment}}
@ -115,4 +113,4 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
partial void PostResolve(); partial void PostResolve();
} }
} {{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -1,8 +1,8 @@
using Bright.Serialization; using Bright.Serialization;
using System.Collections.Generic; using System.Collections.Generic;
namespace {{x.namespace_with_top_module}}
{ {{cs_start_name_space_grace x.namespace_with_top_module}}
{{ {{
name = x.name name = x.name
key_type = x.key_ttype key_type = x.key_ttype
@ -170,4 +170,4 @@ public partial class {{name}}
partial void PostResolve(); partial void PostResolve();
} }
} {{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -6,9 +6,8 @@ using Bright.Serialization;
tables = x.tables tables = x.tables
}} }}
namespace {{namespace}}
{
{{cs_start_name_space_grace x.namespace_with_top_module}}
public partial class {{name}} public partial class {{name}}
{ {
{{~for table in tables ~}} {{~for table in tables ~}}
@ -46,4 +45,4 @@ public partial class {{name}}
partial void PostResolve(); partial void PostResolve();
} }
} {{cs_end_name_space_grace x.namespace_with_top_module}}

View File

@ -10,8 +10,7 @@ using SimpleJSON;
fields = x.fields fields = x.fields
}} }}
namespace {{x.namespace_with_editor_top_module}} {{cs_start_name_space_grace x.namespace_with_editor_top_module}}
{
{{~if x.comment != '' ~}} {{~if x.comment != '' ~}}
/// <summary> /// <summary>
@ -108,3 +107,5 @@ public {{x.cs_class_modifier}} partial class {{name}} : {{if parent_def_type}} {
{{~end~}} {{~end~}}
} }
} }
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}

View File

@ -5,9 +5,7 @@
itemType = 'Bright.Config.EditorEnumItemInfo' itemType = 'Bright.Config.EditorEnumItemInfo'
~}} ~}}
namespace {{x.namespace_with_editor_top_module}} {{cs_start_name_space_grace x.namespace_with_editor_top_module}}
{
{{~if comment != '' ~}} {{~if comment != '' ~}}
/// <summary> /// <summary>
/// {{comment | html.escape}} /// {{comment | html.escape}}
@ -58,4 +56,5 @@ namespace {{x.namespace_with_editor_top_module}}
return __items.Find(c => c.Value == value); return __items.Find(c => c.Value == value);
} }
} }
}
{{cs_end_name_space_grace x.namespace_with_editor_top_module}}