예제 #1
0
        public void WriteExpression(TextWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException(nameof(writer));
            }

            TextWriter       w       = null;
            TypeScriptWriter visitor = null;

            _CachedTextWriter?.TryGetTarget(out w);

            if (w == writer && _CachedTypeScriptWriter?.TryGetTarget(out visitor) == true)
            {
                Accept(visitor);
            }
            else
            {
                visitor                 = new TypeScriptWriter(writer);
                _CachedTextWriter       = new WeakReference <TextWriter>(writer);
                _CachedTypeScriptWriter = new WeakReference <TypeScriptWriter>(visitor);

                Accept(visitor);
            }
        }
예제 #2
0
        public override string ToString()
        {
            using (var w = new StringWriter())
                using (var tsw = new TypeScriptWriter(w))
                {
                    tsw.Write(this);
                    tsw.Flush();

                    return(w.ToString());
                }
        }
예제 #3
0
        private static void AssertStatement(Statement expression, string expected)
        {
            using (var sw = new StringWriter())
            {
                var tsw = new TypeScriptWriter(sw);

                expression.Accept(tsw);

                Assert.AreEqual(expected, sw.ToString());
            }
        }
예제 #4
0
 /// <summary>
 /// <see cref="InterfaceMemberVisitor" /> クラスの新しいインスタンスを初期化します。
 /// </summary>
 public InterfaceMemberVisitor(TypeScriptWriter writer, bool isObjectLiteral)
 {
     _Writer          = writer;
     _IsObjectLiteral = isObjectLiteral;
 }
예제 #5
0
 public ClassMemberVisitor(TypeScriptWriter writer, bool isDeclare)
 {
     _Writer    = writer;
     _IsDeclare = isDeclare;
 }