示例#1
0
        public JsNode VisitConversionResolveResult(ConversionResolveResult res)
        {
            var input          = res.Input;
            var conversion     = res.Conversion;
            var conversionType = res.Type;

            var info = res.GetInfo();

            if (info == null)
            {
                info = new ResolveResultInfo {
                    Conversion = conversion, ResolveResult = res, ConversionTargetType = res.Type
                };
                res.SetInfo(info);
            }
            var info2 = input.GetInfo();

            if (info2 == null)
            {
                input.SetInfo(new ResolveResultInfo {
                    Nodes = info.Nodes.ToList(), Conversion = conversion, ConversionTargetType = res.Type, ResolveResult = input
                });
            }
            if (conversion.IsUserDefined && res.Type.FullName == "SharpKit.JavaScript.JsCode" && input is ConstantResolveResult)
            {
                var value = ((ConstantResolveResult)input).ConstantValue;
                var node3 = Js.CodeExpression(value == null ? "null" : value.ToString());
                return(node3);
            }
            return(VisitConversion(input, conversion, conversionType));
        }
示例#2
0
        public JsNode VisitConversionResolveResult(ConversionResolveResult res)
        {
            var input          = res.Input;
            var conversion     = res.Conversion;
            var conversionType = res.Type;

            var info = res.GetInfo();

            if (info == null)
            {
                info = new ResolveResultInfo {
                    Conversion = conversion, ResolveResult = res, ConversionTargetType = res.Type
                };
                res.SetInfo(info);
            }
            var info2 = input.GetInfo();

            if (info2 == null)
            {
                input.SetInfo(new ResolveResultInfo {
                    Nodes = info.Nodes.ToList(), Conversion = conversion, ConversionTargetType = res.Type, ResolveResult = input
                });
            }
            if (conversion.IsUserDefined && res.Type.FullName == "SharpKit.JavaScript.JsCode" && input is ConstantResolveResult)
            {
                var value = ((ConstantResolveResult)input).ConstantValue;
                var node3 = Js.CodeExpression(value == null ? "null" : value.ToString());
                return(node3);
            }

            #region 修复c#方法重载导致转js后绑定错误
            var tInfo = input.Tag as ResolveResultInfo;
            if (tInfo != null && tInfo.Conversion != null && tInfo.Conversion.Method != null &&
                conversion != null && conversion.Method != null)
            {
                if (tInfo.Conversion.Method.ToString() != conversion.Method.ToString())
                {
                    //var tMessage = string.Format("方法绑定异常:绑定了错误的方法:{0}\n正确的绑定应该是:{1}", tInfo.Conversion.Method.ToString(), conversion.Method.ToString());
                    //Log.Error(tMessage);

                    //处理方法绑定异常
                    var tNewTag = res.Tag as ResolveResultInfo;
                    var tTag    = input.Tag as ResolveResultInfo;
                    tTag.Conversion           = tNewTag.Conversion;
                    tTag.ConversionTargetType = tNewTag.ConversionTargetType;
                    tTag.ResolveResult        = tNewTag.ResolveResult;
                }
            }
            #endregion

            return(VisitConversion(input, conversion, conversionType));
        }