当前位置: 首页>>代码示例>>C#>>正文


C# IExpr.ConstantOptimization方法代码示例

本文整理汇总了C#中IExpr.ConstantOptimization方法的典型用法代码示例。如果您正苦于以下问题:C# IExpr.ConstantOptimization方法的具体用法?C# IExpr.ConstantOptimization怎么用?C# IExpr.ConstantOptimization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IExpr的用法示例。


在下文中一共展示了IExpr.ConstantOptimization方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FinalPass

        internal override void FinalPass()
        {
            // optimization: avoid expression overhead if this isn't really an expression
            if (_Source == null)
            {
                _Expr = new Constant("");
                return;
            }
            else if (_Source == "" ||			// empty expression
                _Source[0] != '=')	// if 1st char not '='
            {
                _Expr = new Constant(_Source);	//   this is a constant value
                return;
            }

            Parser p = new Parser(OwnerReport.DataCache);

            // find the fields that are part of the DataRegion (if there is one)
            IDictionary fields=null;
            ReportLink dr = Parent;
            Grouping grp= null;		// remember if in a table group or detail group or list group
            Matrix m=null;
            ReportLink phpf=null;
            while (dr != null)
            {
                if (dr is Grouping)
                    p.NoAggregateFunctions = true;
                else if (dr is TableGroup)
                    grp = ((TableGroup) dr).Grouping;
                else if (dr is Matrix)
                {
                    m = (Matrix) dr;		// if matrix we need to pass special
                    break;
                }
                else if (dr is Details)
                {
                    grp = ((Details) dr).Grouping;
                }
                else if (dr is List)
                {
                    grp = ((List) dr).Grouping;
                    break;
                }
                else if (dr is PageHeader || dr is PageFooter)
                {
                    phpf = dr;
                }
                else if (dr is DataRegion || dr is DataSetDefn)
                    break;
                dr = dr.Parent;
            }
            if (dr != null)
            {
                if (dr is DataSetDefn)
                {
                    DataSetDefn d = (DataSetDefn) dr;
                    if (d.Fields != null)
                        fields = d.Fields.Items;
                }
                else	// must be a DataRegion
                {
                    DataRegion d = (DataRegion) dr;
                    if (d.DataSetDefn != null &&
                        d.DataSetDefn.Fields != null)
                        fields = d.DataSetDefn.Fields.Items;
                }
            }

            NameLookup lu = new NameLookup(fields, OwnerReport.LUReportParameters,
                OwnerReport.LUReportItems,OwnerReport.LUGlobals,
                OwnerReport.LUUser, OwnerReport.LUAggrScope,
                grp, m, OwnerReport.CodeModules, OwnerReport.Classes, OwnerReport.DataSetsDefn,
                OwnerReport.CodeType);

            if (phpf != null)
            {
                // Non-null when expression is in PageHeader or PageFooter;
                //   Expression name needed for dynamic lookup of ReportItems on a page.
                lu.PageFooterHeader = phpf;
                lu.ExpressionName = _UniqueName = "xn_" + Interlocked.Increment(ref Parser.Counter).ToString();
            }

            try
            {
                _Expr = p.Parse(lu, _Source);
            }
            catch (Exception e)
            {
                _Expr = new ConstantError(e.Message);
                // Invalid expression
                OwnerReport.rl.LogError(8, ErrorText(e.Message));
            }

            // Optimize removing any expression that always result in a constant
            try
            {
                _Expr = _Expr.ConstantOptimization();
            }
            catch(Exception ex)
            {
//.........这里部分代码省略.........
开发者ID:bittercoder,项目名称:reportingcloud,代码行数:101,代码来源:Expression.cs

示例2: DoParse

		public TypeCode DoParse(Report rpt)
		{
			// optimization: avoid expression overhead if this isn't really an expression
			if (_Source == null)
			{
				_Expr = new Constant("");
                return _Expr.GetTypeCode();
			}
			else if (_Source == string.Empty ||			// empty expression
				_Source[0] != '=')	// if 1st char not '='
			{
				_Expr = new Constant(_Source);	//   this is a constant value
                return _Expr.GetTypeCode();
			}

			Parser p = new Parser(new System.Collections.Generic.List<ICacheData>());

			// find the fields that are part of the DataRegion (if there is one)
			IDictionary fields=null;
			ReportLink dr = _rl.Parent;
			Grouping grp= null;		// remember if in a table group or detail group or list group
			Matrix m=null;

            while (dr != null)
			{
				if (dr is Grouping)
					p.NoAggregateFunctions = true;
				else if (dr is TableGroup)
					grp = ((TableGroup) dr).Grouping;
				else if (dr is Matrix)
				{
					m = (Matrix) dr;		// if matrix we need to pass special
					break;
				}
				else if (dr is Details)
				{
					grp = ((Details) dr).Grouping;
				}
				else if (dr is List)
				{
					grp = ((List) dr).Grouping;
					break;
				}
				else if (dr is DataRegion || dr is DataSetDefn)
					break;
				dr = dr.Parent;
			}
			if (dr != null)
			{
				if (dr is DataSetDefn)
				{
					DataSetDefn d = (DataSetDefn) dr;
					if (d.Fields != null)
						fields = d.Fields.Items;
				}
				else	// must be a DataRegion
				{
					DataRegion d = (DataRegion) dr;
					if (d.DataSetDefn != null &&
						d.DataSetDefn.Fields != null)
						fields = d.DataSetDefn.Fields.Items;
				}
			}

			NameLookup lu = new NameLookup(fields, rpt.ReportDefinition.LUReportParameters,
                rpt.ReportDefinition.LUReportItems, rpt.ReportDefinition.LUGlobals,
                rpt.ReportDefinition.LUUser, rpt.ReportDefinition.LUAggrScope,
                grp, m, rpt.ReportDefinition.CodeModules, rpt.ReportDefinition.Classes, rpt.ReportDefinition.DataSetsDefn,
                rpt.ReportDefinition.CodeType);

			try 
			{
				_Expr = p.Parse(lu, _Source);
			}
			catch (Exception e)
			{
				_Expr = new ConstantError(e.Message);
				// Invalid expression
				rpt.rl.LogError(8, ErrorText(e.Message));
			}

			// Optimize removing any expression that always result in a constant
			try
			{
				_Expr = _Expr.ConstantOptimization();
			}
			catch(Exception ex)
			{
				rpt.rl.LogError(4, "Expression:" + _Source + "\r\nConstant Optimization exception:\r\n" + ex.Message + "\r\nStack trace:\r\n" + ex.StackTrace );
			}

            return _Expr.GetTypeCode();
		}
开发者ID:JackWangCUMT,项目名称:rdlc.report.engine,代码行数:93,代码来源:DynamicExpression.cs


注:本文中的IExpr.ConstantOptimization方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。