/// <summary> /// 文字列取得 /// </summary> /// <param name="index">前スペース数</param> /// <returns>文字列</returns> public override string ToString(int index = 0) { var result = new StringBuilder(); var indexSpace = string.Concat(Enumerable.Repeat(" ", index)); foreach (var comment in Comments) { result.Append(indexSpace); result.AppendLine($"{comment}"); } foreach (var modifier in Modifiers) { result.Append(indexSpace); result.Append($"{modifier} "); } result.Append($"class {Name}"); // ジェネリックタイプ if (GenericTypes.Any()) { result.Append("<"); GenericTypes.ForEach(item => { result.Append(item); if (GenericTypes.IndexOf(item) > 0) { result.Append(", "); } }); result.Append(">"); } // スーパークラス/インターフェイス if (SuperClass.Any()) { result.Append(" : "); SuperClass.ForEach(item => { result.Append(item.Name); }); } if (Interfaces.Any()) { if (SuperClass.Any()) { result.Append(", "); } Interfaces.ForEach(item => { if (Interfaces.IndexOf(item) > 0) { result.Append(", "); } item.ForEach(expression => { result.Append(expression.Name); }); }); } result.AppendLine(); result.Append(indexSpace); result.AppendLine("{"); Members.ForEach(member => result.AppendLine(member.ToString(index + 1))); result.Append(indexSpace); result.AppendLine("}"); return(result.ToString()); }