예제 #1
0
        private void FillTagOpen(int argsFrom, IExternalTranslationContext ctx, CsharpMethodCallExpression src, string end)
        {
            var tagName = src.Arguments[0];
            Append("<");
            Append(tagName);
            for (var i = argsFrom + 1; i < src.Arguments.Length; i += 2)
            {
                var key = src.Arguments[i - 1];
                var value = src.Arguments[i];
                Append(" ");
                Append(key);
                Append("=\"");
                Append(value);
                Append("\"");
            }
            Append(end);

        }
예제 #2
0
        // Public Methods 

        public void CheckAccesibility(CsharpMethodCallExpression m)
        {
            if (m == null)
                return;
            CheckAccesibility(m.MethodInfo);
        }
예제 #3
0
        // Public Methods 

        public IPhpValue TranslateToPhp(IExternalTranslationContext ctx, CsharpMethodCallExpression src)
        {
            if (src.MethodInfo.DeclaringType == typeof(Html))
            {
                this.ctx = ctx;
                list = new List<IPhpValue>();
                var methodName = src.MethodInfo.Name;
                var isecho = methodName.StartsWith("Echo");
                if (isecho)
                    methodName = methodName.Substring(4);
                if (methodName == "TagBound")
                {
                    FillTagOpen(2, ctx, src, ">");
                    Append(src.Arguments[1]);
                    FillTagEnd(src.Arguments[0]);
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "Attributes")
                {
                    for (var i = 1; i < src.Arguments.Length; i += 2)
                    {
                        var key = src.Arguments[i - 1];
                        var value = src.Arguments[i];
                        Append(" ");
                        Append(key);
                        Append("=\"");
                        Append(value);
                        Append("\"");
                    }
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "TagOpen" || methodName == "TagSingle")
                {
                    var end = methodName == "TagOpen" ? ">" : " />";
                    FillTagOpen(1, ctx, src, end);
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "TagOpenOpen")
                {
                    FillTagOpen(1, ctx, src, "");
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "TagClose")
                {
                    FillTagEnd(src.Arguments[0]);
                    if (src.Arguments.Length == 2)
                    {
//                        throw new NotSupportedException();
                        Append("\r\n");
                    }
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "Comment")
                {
                    Append("<!-- ");
                    Append(src.Arguments[0]);
                    Append(" -->");
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "Pixels" || methodName == "Percent")
                {
                    Append(src.Arguments[0]);
                    Append(methodName == "Pixels" ? "px" : "%");
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "Mm")
                {
                    Append(src.Arguments[0]);
                    Append("mm");
                    return MakeEchoIfNecessary(isecho);
                }

                if (methodName == "Css")
                {
                    for (var i = 1; i < src.Arguments.Length; i += 2)
                    {
                        var key = src.Arguments[i - 1];
                        var value = src.Arguments[i];
                        Append(key);
                        Append(":");
                        Append(value);
                        Append(";");
                    }
                    return MakeEchoIfNecessary(isecho);
                }
                if (methodName == "CssBorder")
                {
                    Append(src.Arguments[0]);
                    Append(" ");
                    Append(src.Arguments[1]);
                    Append(" ");
                    Append(src.Arguments[2]);
                    return MakeEchoIfNecessary(isecho);
                }
                throw new NotSupportedException();
            }
            return null;
        }