Skip to content

Commit

Permalink
.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Sep 30, 2022
2 parents ebcc409 + b639067 commit eb0695b
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions src/UnitGenerator/CodeTemplate.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// ------------------------------------------------------------------------------
// <auto-generated>
// このコードはツールによって生成されました。
// ランタイム バージョン: 17.0.0.0
// This code was generated by a tool.
// Runtime Version: 17.0.0.0
//
// このファイルへの変更は、正しくない動作の原因になる可能性があり、
// コードが再生成されると失われます。
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
// ------------------------------------------------------------------------------
namespace UnitGenerator
Expand Down Expand Up @@ -163,21 +163,36 @@ public virtual string TransformText()
if (HasFlag(UnitGenerateOptions.ParseMethod)) {
this.Write(" \r\n // UnitGenerateOptions.ParseMethod\r\n\r\n public static ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write(" Parse(string s)\r\n {\r\n return new ");
this.Write(" Parse(string s)\r\n {\r\n");
if (Type == "string") {
this.Write(" return new ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("(s);\r\n");
} else {
this.Write(" return new ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("(");
this.Write(this.ToStringHelper.ToStringWithCulture(Type));
this.Write(".Parse(s));\r\n }\r\n \r\n public static bool TryParse(string s, o" +
"ut ");
this.Write(".Parse(s));\r\n");
}
this.Write(" }\r\n \r\n public static bool TryParse(string s, out ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write(" result)\r\n {\r\n if(");
this.Write(" result)\r\n {\r\n");
if (Type == "string") {
this.Write(" try\r\n {\r\n result = Parse(s); \r\n " +
" return true;\r\n } \r\n catch \r\n {\r\n " +
" result = default;\r\n return false;\r\n }\r\n");
} else {
this.Write(" if(");
this.Write(this.ToStringHelper.ToStringWithCulture(Type));
this.Write(".TryParse(s, out var r))\r\n {\r\n result = new ");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write("(r);\r\n return true;\r\n }\r\n else\r\n " +
"{\r\n result = default(");
this.Write(this.ToStringHelper.ToStringWithCulture(Name));
this.Write(");\r\n return false;\r\n }\r\n }\r\n\r\n");
this.Write(");\r\n return false;\r\n }\r\n");
}
this.Write(" }\r\n\r\n");
}
this.Write("\r\n");
if (HasFlag(UnitGenerateOptions.MinMaxMethod)) {
Expand Down

0 comments on commit eb0695b

Please sign in to comment.