Esempio n. 1
0
        /// <summary>
        /// 変換メソッド:else
        /// </summary>
        /// <param name="item">C#解析結果</param>
        /// <param name="config">設定情報</param>
        /// <param name="indent">インデント数</param>
        /// <param name="otherScripts">その他のスクリプト(内部クラスなど)</param>
        /// <returns>TypeScript変換結果</returns>
        private string Convert(IItemElseClause item, Config config, int indent, List <string> otherScripts)
        {
            var result      = new StringBuilder();
            var indentSpace = GetIndentSpace(indent);

            // コメント
            result.Append(GetTypeScriptComments(item, indentSpace));

            // 定義
            if (item.Conditions.Any())
            {
                result.AppendLine($"{indentSpace}else if ({ConvertConditions(item.Conditions)}) {{");
            }
            else
            {
                result.AppendLine($"{indentSpace}else {{");
            }

            // メンバー追加
            foreach (var member in item.Block)
            {
                result.Append(ConvertUtility.Convert(member, config, indent + 1, otherScripts));
            }

            result.AppendLine($"{indentSpace}}}");

            return(result.ToString());
        }
Esempio n. 2
0
        /// <summary>
        /// ELSEステートメントの確認
        /// </summary>
        /// <param name="target">対象インスタンス</param>
        /// <param name="condition">条件式</param>
        private bool checkElse(IItemElseClause target, string condition)
        {
            Assert.NotNull(target);
            Assert.Equal(condition, GetExpressionsToString(target.Conditions));

            return(true);
        }