diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
index 25c06014cd..9155c8a754 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/ICSharpCode.Reporting.csproj
@@ -95,7 +95,11 @@
+
+
+
+
@@ -115,8 +119,10 @@
+
+
@@ -166,6 +172,7 @@
+
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs
new file mode 100644
index 0000000000..25cbfc51c4
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/FieldMemberAccessor.cs
@@ -0,0 +1,35 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Reflection;
+
+namespace ICSharpCode.Reporting.DataSource
+{
+ ///
+ /// Description of FieldMemberAccessor.
+ ///
+ public class FieldMemberAccessor : IMemberAccessor
+ {
+ private readonly FieldInfo _field;
+
+ public FieldMemberAccessor(FieldInfo field)
+ {
+ _field = field;
+ }
+
+ public object GetValue(object target)
+ {
+ return _field.GetValue(target);
+ }
+
+ public bool IsStatic
+ {
+ get { return _field.IsStatic; }
+ }
+
+ public Type MemberType
+ {
+ get { return _field.FieldType;}
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs
new file mode 100644
index 0000000000..f7c333cbe8
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyMemberAccessore.cs
@@ -0,0 +1,42 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Reflection;
+
+namespace ICSharpCode.Reporting.DataSource
+{
+ ///
+ /// Description of PropertyMemberAccessore.
+ ///
+ public interface IMemberAccessor
+ {
+ object GetValue(object target);
+ bool IsStatic { get; }
+ Type MemberType { get; }
+ }
+
+ public class PropertyMemberAccessor : IMemberAccessor
+ {
+ private readonly PropertyInfo _prop;
+
+ public PropertyMemberAccessor(PropertyInfo prop)
+ {
+ _prop = prop;
+ }
+
+ public object GetValue(object target)
+ {
+ return _prop.GetValue(target, null);
+ }
+
+ public bool IsStatic
+ {
+ get { return _prop.GetGetMethod().IsStatic; }
+ }
+
+ public Type MemberType
+ {
+ get { return _prop.PropertyType;}
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs
new file mode 100644
index 0000000000..0a242aa694
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/PropertyPath.cs
@@ -0,0 +1,88 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Text;
+
+namespace ICSharpCode.Reporting.DataSource
+{
+ public class PropertyPath
+ {
+ private readonly Type _rootType;
+ private readonly IMemberAccessor[] _properties;
+ private readonly bool _rootIsStatic;
+
+ private PropertyPath(Type rootType,IMemberAccessor[] props)
+ {
+ _properties = props;
+ _rootType = rootType;
+
+ if (_properties[0].IsStatic)
+ _rootIsStatic = true;
+ }
+
+ public object Evaluate(object target)
+ {
+ if (target == null && _rootIsStatic == false)
+ return null;
+
+// Type s = target.GetType();
+
+ if (target != null && _rootType.IsAssignableFrom(target.GetType()) == false)
+ return null;
+
+
+ object current = target;
+ foreach (IMemberAccessor prop in _properties)
+ {
+ current = prop.GetValue(current);
+ if (current == null)
+ return null;
+ }
+ return current;
+ }
+
+ public static PropertyPath Parse(Type targetType,string propPath)
+ {
+ if (String.IsNullOrEmpty(propPath))
+ return null;
+
+ string[] parts = propPath.Split('.');
+ return Compile(targetType, parts);
+
+ }
+
+ public static PropertyPath Compile(Type targetType,string[] pathParts)
+ {
+ var accessors = new IMemberAccessor[pathParts.Length];
+
+ Type currentType = targetType;
+ for (int i = 0; i < pathParts.Length; i++)
+ {
+ string part = pathParts[i];
+
+ IMemberAccessor accessor = currentType.FindAccessor(part);
+ if (accessor == null)
+ return null;
+
+
+ accessors[i] = accessor;
+ currentType = accessor.MemberType;
+ }
+
+ return new PropertyPath(targetType, accessors);
+ }
+
+ public static string GetCacheKey(Type targetType,string[] name)
+ {
+ var key = new StringBuilder();
+ key.Append(targetType.FullName);
+ foreach (string namePart in name)
+ key.Append(namePart);
+ return key.ToString();
+ }
+
+
+
+ }
+
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs
new file mode 100644
index 0000000000..3c912af459
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/DataSource/ReflectionExtension.cs
@@ -0,0 +1,53 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Reflection;
+
+
+namespace ICSharpCode.Reporting.DataSource
+{
+ ///
+ /// Description of ReflectionExtension.
+ ///
+ ///
+
+
+
+ public static class ReflectionExtensions
+ {
+ public static PropertyPath ParsePropertyPath(this object target,string propertyPath)
+ {
+ if (target == null || String.IsNullOrEmpty(propertyPath))
+ return null;
+
+ return PropertyPath.Parse(target.GetType(), propertyPath);
+ }
+
+
+ public static object EvaluatePropertyPath(this object target,string propertyPath)
+ {
+ PropertyPath path = ParsePropertyPath(target, propertyPath);
+ if (path != null)
+ return path.Evaluate(target);
+ return null;
+ }
+
+
+ public static IMemberAccessor FindAccessor(this Type type, string accessorName)
+ {
+ PropertyInfo prop = type.GetProperty(accessorName,
+ BindingFlags.IgnoreCase | BindingFlags.NonPublic |
+ BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
+ if (prop != null)
+ return new PropertyMemberAccessor(prop);
+
+ FieldInfo field = type.GetField(accessorName,
+ BindingFlags.IgnoreCase | BindingFlags.NonPublic |
+ BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance);
+ if (field != null)
+ return new FieldMemberAccessor(field);
+
+ return null;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs
index cc2a296a0a..b924d16c74 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Exporter/Visitors/ExpressionVisitor.cs
@@ -19,6 +19,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
readonly ReportingLanguageGrammer grammar;
readonly ReportingExpressionEvaluator evaluator;
+
public ExpressionVisitor(Collection pages,ReportSettings reportSettings):this(reportSettings)
{
this.pages = pages;
@@ -59,7 +60,7 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
object result = Evaluate(exportColumn);
exportColumn.Text = result.ToString();
} catch (Exception e) {
- var s = String.Format("SharpReport.Exprssions -> {0} for {1}",e.Message,exportColumn.Text);
+ var s = String.Format("SharpReport.Expressions -> {0} for {1}",e.Message,exportColumn.Text);
Console.WriteLine(s);
}
}
@@ -72,5 +73,10 @@ namespace ICSharpCode.Reporting.Exporter.Visitors
var result = evaluator.Evaluate(str);
return result;
}
+
+ public ReportingExpressionEvaluator Evaluator {
+ get { return evaluator; }
+ }
+
}
}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs
new file mode 100644
index 0000000000..666c391667
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/Imports/ImportAggregates.cs
@@ -0,0 +1,58 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+
+using ICSharpCode.Reporting.DataManager.Listhandling;
+using ICSharpCode.Reporting.DataSource;
+using Irony.Interpreter;
+using Irony.Interpreter.Ast;
+
+
+namespace ICSharpCode.Reporting.Expressions.Irony.Imports
+{
+ ///
+ /// Description of ImportAggregates.
+ ///
+ public static class ImportAggregates
+ {
+ public static object Sum(ScriptThread thread, AstNode[] childNodes) {
+ double sum = 0;
+ var fieldName = childNodes[0].Evaluate(thread).ToString();
+
+ var dataSource = (CollectionSource)thread.App.Globals["Current"];
+
+ var curpos = dataSource.CurrentPosition;
+
+ dataSource.CurrentPosition = 0;
+
+ if (FieldExist(dataSource.Current,fieldName)) {
+ do {
+ var current = dataSource.Current;
+ var property = current.ParsePropertyPath(fieldName);
+ var val = property.Evaluate(current);
+ var nextVal = TypeNormalizer.EnsureType(val);
+ sum = sum + nextVal;
+ }
+ while (dataSource.MoveNext());
+ }
+
+ dataSource.CurrentPosition = curpos;
+ return sum;
+ }
+
+
+ static bool FieldExist (object current,string fieldName) {
+ var property1 = current.ParsePropertyPath(fieldName);
+ if (property1 == null) {
+ Console.WriteLine(String.Format("Aggregate Field '{0}' not found",fieldName));
+ return false;
+ }
+ return true;
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs
index 5fed9484e6..e29f3a4fc8 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageGrammer.cs
@@ -48,7 +48,7 @@ bool operations &,&&, |, ||; ternary '?:' operator." ;
// 2. Non-terminals
var Term = new NonTerminal("Term");
var BinExpr = new NonTerminal("BinExpr", typeof(BinaryOperationNode));
- var ParExpr = new NonTerminal("ParExpr");
+ var ParExpr = new NonTerminal("ParExsumpr");
var UnExpr = new NonTerminal("UnExpr", typeof(UnaryOperationNode));
var TernaryIfExpr = new NonTerminal("TernaryIf", typeof(IfNode));
var ArgList = new NonTerminal("ArgList", typeof(ExpressionListNode));
@@ -105,18 +105,10 @@ bool operations &,&&, |, ||; ternary '?:' operator." ;
ParametersSection.Rule = ToTerm("Parameters") + exclamationMark + identifier;
FieldsSection.Rule = ToTerm("Fields") + exclamationMark + identifier;
- GlobalSection.Rule = ToTerm("Globals") + exclamationMark + identifier;
+ GlobalSection.Rule = ToTerm("Globals") + exclamationMark + identifier;
-// GlobalSection.Rule = ToTerm("Globals") + exclamationMark + ToTerm("PageNumber");
-
- /*
- GlobalSection.Rule = GlobalSection + exclamationMark + Symbol("PageNumber")
- | GlobalSection + exclamationMark + Symbol("TotalPages")
- | GlobalSection + exclamationMark + Symbol("ExecutionTime")
- | GlobalSection + exclamationMark + Symbol("ReportFolder")
- | GlobalSection + exclamationMark + Symbol("ReportName");
- */
// end of SharpReporting
+
FunctionCall.NodeCaptionTemplate = "call #{0}(...)";
ObjectRef.Rule = identifier | MemberAccess | IndexedAccess;
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs
index d8df13c486..aa9d4cfcd2 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/Irony/ReportingLanguageRuntime.cs
@@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using System.Linq;
+using ICSharpCode.Reporting.Expressions.Irony.Imports;
using Irony.Interpreter;
using Irony.Parsing;
@@ -21,14 +22,15 @@ namespace ICSharpCode.Reporting.Expressions.Irony
base.Init();
//add built-in methods, special form IIF, import Math and Environment methods
// BuiltIns.AddMethod(BuiltInPrintMethod, "print");
- BuiltIns.AddMethod(BuiltInFormatMethod, "format");
+// BuiltIns.AddMethod(BuiltInFormatMethod, "format");
BuiltIns.AddSpecialForm(SpecialFormsLibrary.Iif, "iif", 3, 3);
BuiltIns.ImportStaticMembers(typeof(System.Math));
BuiltIns.ImportStaticMembers(typeof(Environment));
+ BuiltIns.AddSpecialForm(ImportAggregates.Sum,"sum",1,1);
}
-
+ /*
private object BuiltInPrintMethod(ScriptThread thread, object[] args) {
string text = string.Empty;
switch(args.Length) {
@@ -44,7 +46,9 @@ namespace ICSharpCode.Reporting.Expressions.Irony
thread.App.WriteLine(text);
return null;
}
+ */
+ /*
private object BuiltInFormatMethod(ScriptThread thread, object[] args) {
if (args == null || args.Length == 0) return null;
var template = args[0] as string;
@@ -57,6 +61,6 @@ namespace ICSharpCode.Reporting.Expressions.Irony
return text;
}
-
+ */
}
}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs
new file mode 100644
index 0000000000..55811f7f51
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Expressions/TypeNormalizer.cs
@@ -0,0 +1,106 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+
+namespace ICSharpCode.Reporting.Expressions
+{
+ ///
+ /// Description of TypeNormalizer.
+ ///
+ public class TypeNormalizer
+ {
+
+ public static void NormalizeTypes(ref object left,ref object right)
+ {
+ NormalizeTypes(ref left,ref right,0);
+ }
+
+ public static void NormalizeTypes(ref object left,ref object right,object nullValue)
+ {
+ if (left == null)
+ left = 0;
+ if (right == null)
+ right = 0;
+
+ if (left.GetType() == right.GetType())
+ return;
+
+ try
+ {
+ right = Convert.ChangeType(right,left.GetType());
+ }
+ catch
+ {
+ try
+ {
+ left = Convert.ChangeType(left, right.GetType());
+ }
+ catch
+ {
+ throw new Exception(String.Format("Error converting from {0} type to {1}", left.GetType().FullName, right.GetType().FullName));
+ }
+ }
+ }
+
+ public static void EnsureTypes(ref object[] values,Type targetType)
+ {
+ object nullValue = null;
+ if (targetType.IsValueType)
+ nullValue = Activator.CreateInstance(targetType);
+ EnsureTypes(ref values,targetType,nullValue);
+
+ }
+
+ public static void EnsureTypes(ref object[] values,Type targetType,object nullValue)
+ {
+ for (int i=0;i(object value)
+ {
+ return EnsureType(value, default(T));
+ }
+
+ public static T EnsureType(object value,object nullValue)
+ {
+ return (T) EnsureType(value, typeof (T), nullValue);
+ }
+
+ public static object EnsureType(object value, Type targetType)
+ {
+ if (value != null && value.GetType() == targetType)
+ return value;
+
+ object defaultValue = null;
+ if (targetType.IsValueType)
+ defaultValue = Activator.CreateInstance(targetType);
+ return EnsureType(value, targetType, defaultValue);
+ }
+
+ public static object EnsureType(object value,Type targetType,object nullValue)
+ {
+ if (value == null)
+ return nullValue;
+
+ if (targetType == typeof(object))
+ return value;
+
+ if (value.GetType() == targetType)
+ return value;
+
+ try {
+ return Convert.ChangeType(value, targetType);
+ } catch (Exception e) {
+
+ Console.WriteLine("TypeNormalizer {0} - {1}",value.ToString(),e.Message);
+ return value.ToString();
+ //throw new Exception()String.Format("TypeNormalizer for <{0}> - {1}",value.ToString(),e.Message));
+ }
+ }
+
+ }
+}
+
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
index 61d89fe965..83bd2ce30f 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/ICSharpCode.Reporting.Test.csproj
@@ -66,12 +66,13 @@
-
-
-
-
+
+
+
+
+
+
-
@@ -91,7 +92,8 @@
-
+
+
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs
new file mode 100644
index 0000000000..e4b6041df1
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/AggregateFuctionHelper.cs
@@ -0,0 +1,46 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Collections.Generic;
+
+namespace ICSharpCode.Reporting.Test.Expressions.Aggregates
+{
+ ///
+ /// Description of AggregateFuctionHelper.
+ ///
+ internal class AggregateFuctionHelper
+ {
+
+ public AggregateFuctionHelper()
+ {
+ this.AggregateCollection = new AggregateCollection();
+ this.AggregateCollection.Add (new Aggregate("Value1",1,1.5));
+ this.AggregateCollection.Add (new Aggregate("Value2",2,2.5));
+ this.AggregateCollection.Add (new Aggregate("Value3",3,3.5));
+ this.AggregateCollection.Add (new Aggregate("Value400",400,400.75));
+ }
+
+
+ public AggregateCollection AggregateCollection {get; private set;}
+
+ }
+
+
+ class AggregateCollection: List
+ {
+ }
+
+
+ class Aggregate {
+ public Aggregate (string name,int intValue, double amount)
+ {
+ this.Name = name;
+ this.IntValue = intValue;
+ this.DoubleValue = amount;
+ }
+
+ public string Name {get;set;}
+ public int IntValue {get;set;}
+ public double DoubleValue {get;set;}
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregate.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregate.cs
new file mode 100644
index 0000000000..9c443488e2
--- /dev/null
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/Aggregates/SumAggregate.cs
@@ -0,0 +1,72 @@
+// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
+// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
+using System;
+using System.Collections.ObjectModel;
+using ICSharpCode.Reporting.DataManager.Listhandling;
+using ICSharpCode.Reporting.Exporter.Visitors;
+using ICSharpCode.Reporting.Items;
+using ICSharpCode.Reporting.PageBuilder.ExportColumns;
+using NUnit.Framework;
+
+namespace ICSharpCode.Reporting.Test.Expressions.Aggregates
+{
+ [TestFixture]
+ public class SumAggregate
+ {
+
+ Collection collection;
+ ExpressionVisitor expressionVisitor;
+ AggregateCollection agc;
+ AggregateFuctionHelper helper;
+ CollectionSource cs;
+
+ [Test]
+ public void CanSum_Int_WholeCollection()
+ {
+ var reportSettings = new ReportSettings();
+ var visitor = new ExpressionVisitor(reportSettings);
+ var script = "= sum('intValue')";
+ collection[0].Text = script;
+ visitor.Evaluator.Globals.Add("Current",cs);
+ visitor.Visit(collection[0]);
+ Assert.That (collection[0].Text,Is.EqualTo("406"));
+ Assert.That(Convert.ToInt32(collection[0].Text),Is.TypeOf(typeof(int)));
+ }
+
+
+ [Test]
+ public void CanSum_Double_WholeCollection()
+ {
+ var reportSettings = new ReportSettings();
+ var visitor = new ExpressionVisitor(reportSettings);
+ var script = "= sum('doubleValue')";
+ collection[0].Text = script;
+ visitor.Evaluator.Globals.Add("Current",cs);
+ visitor.Visit(collection[0]);
+ Assert.That (collection[0].Text,Is.EqualTo("408,25"));
+ Assert.That(Convert.ToDouble(collection[0].Text),Is.TypeOf(typeof(double)));
+ }
+
+
+
+ [SetUp]
+ public void CreateExportlist() {
+ collection = new Collection();
+ collection.Add(new ExportText()
+ {
+ Text = String.Empty
+ });
+
+ helper = new AggregateFuctionHelper();
+ agc = helper.AggregateCollection;
+ cs = new CollectionSource(agc,typeof(Aggregate),new ReportSettings());
+ cs.Bind();
+ }
+
+
+ [TestFixtureSetUp]
+ public void Setup() {
+ expressionVisitor = new ExpressionVisitor(new ReportSettings());
+ }
+ }
+}
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/FieldsFixture.cs
similarity index 100%
rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/FieldsFixture.cs
rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/FieldsFixture.cs
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/GlobalsFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/GlobalsFixture.cs
similarity index 100%
rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/GlobalsFixture.cs
rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/GlobalsFixture.cs
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/ParametersFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/ParametersFixture.cs
similarity index 100%
rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/ParametersFixture.cs
rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/ParametersFixture.cs
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/StandardTests.cs
similarity index 100%
rename from src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/InterationTests/StandardTests.cs
rename to src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IntegrationTests/StandardTests.cs
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs
index b6ca3f1c7e..83193663b2 100644
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs
+++ b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/IronyGeneral.cs
@@ -62,6 +62,7 @@ namespace ICSharpCode.Reporting.Test.Expressions
Assert.AreEqual(11.0, (double) result, 0.001, "Unexpected computation result");
}
+
#endregion
[SetUp]
diff --git a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/ParametersHandlingFixture.cs b/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/ParametersHandlingFixture.cs
deleted file mode 100644
index 4f48c42d3a..0000000000
--- a/src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/Expressions/ParametersHandlingFixture.cs
+++ /dev/null
@@ -1,118 +0,0 @@
-// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
-// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
-using System;
-using ICSharpCode.Reporting.BaseClasses;
-using ICSharpCode.Reporting.Expressions.Irony;
-using ICSharpCode.Reporting.Expressions.Irony.Ast;
-using ICSharpCode.Reporting.Items;
-using NUnit.Framework;
-
-namespace ICSharpCode.Reporting.Test.Expressions
-{
- [TestFixture]
- public class ParametersHandlingFixture
- {
- ReportingLanguageGrammer grammar;
- ReportingExpressionEvaluator evaluator;
-
- [Test]
- public void CanEvaluateOneParameter()
- {
- var resultValue = "Hi from param1";
- var parameters = new ParameterCollection();
- parameters.Add(new BasicParameter() {
- ParameterName = "param1",
- ParameterValue = resultValue
- }
- );
- AddToGlobals(parameters);
- var script = "Parameters!param1";
- var result = evaluator.Evaluate(script);
- Assert.That (result,Is.EqualTo(resultValue));
- }
-
-
- [Test]
- public void CanFindParameter () {
- var resultValue = "Hi from param2";
- var parameters = new ParameterCollection();
- parameters.Add(new BasicParameter() {
- ParameterName = "param1",
- ParameterValue = "Value for parameter1"
- }
- );
-
- parameters.Add(new BasicParameter() {
- ParameterName = "param2",
- ParameterValue = resultValue
- }
- );
- parameters.Add(new BasicParameter() {
- ParameterName = "param3",
- ParameterValue = "Value for parameter2"
- }
- );
-
-
- AddToGlobals(parameters);
-
- var script = "Parameters!param2";
- var result = evaluator.Evaluate(script);
- Assert.That (result,Is.EqualTo(resultValue));
- }
-
-
- [Test]
- public void CanConcatParameter () {
- var parameters = new ParameterCollection();
- parameters.Add(new BasicParameter() {
- ParameterName = "param1",
- ParameterValue = "SharpDevelop"
- }
- );
-
- parameters.Add(new BasicParameter() {
- ParameterName = "param2",
- ParameterValue = " is "
- }
- );
- parameters.Add(new BasicParameter() {
- ParameterName = "param3",
- ParameterValue = "great"
- }
- );
- AddToGlobals(parameters);
- var script = "Parameters!param1 + Parameters!param2 + Parameters!param3";
- var result = evaluator.Evaluate(script);
- Assert.That (result,Is.EqualTo("SharpDevelop is great"));
- }
-
-
- void AddToGlobals(ParameterCollection parameters)
- {
- var reportSettings = new ReportSettings();
- reportSettings.ParameterCollection.AddRange(parameters);
- evaluator.AddReportSettings(reportSettings);
- }
-
-
- [SetUp]
- public void Initialize() {
- grammar = new ReportingLanguageGrammer();
- evaluator = new ReportingExpressionEvaluator(grammar);
- }
-
-
- [TestFixtureSetUp]
- public void Init()
- {
- // TODO: Add Init code.
- }
-
- [TestFixtureTearDown]
- public void Dispose()
- {
- // TODO: Add tear down code.
- }
- }
-}