示例#1
0
文件: forin.cs 项目: formist/LinkMe
        public override string ToCode(ToCodeFormat format)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append("for(");

            string var = m_var.ToCode();

            sb.Append(var);
            if (JSScanner.EndsWithIdentifierPart(var))
            {
                sb.Append(' ');
            }
            sb.Append("in");

            string collection = m_collection.ToCode();

            if (JSScanner.StartsWithIdentifierPart(collection))
            {
                sb.Append(' ');
            }
            sb.Append(m_collection.ToCode());
            sb.Append(')');

            string bodyString = (
                m_body == null
              ? string.Empty
              : m_body.ToCode()
                );

            sb.Append(bodyString);
            return(sb.ToString());
        }