Browse Source

Change API in ReportingFactory

reports
Peter Forstmeier 13 years ago
parent
commit
cc3c941a88
  1. 60
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs
  2. 2
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs
  3. 25
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs
  4. 12
      src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs

60
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/Collections.cs

@ -17,53 +17,14 @@ using ICSharpCode.Reporting.Items;
namespace ICSharpCode.Reporting namespace ICSharpCode.Reporting
{ {
/// <summary>
/// Description of Collections.
/// </summary>
public class ColumnCollection: Collection<AbstractColumn>{ public class SortColumnCollection: Collection<AbstractColumn>
public ColumnCollection()
{
}
public AbstractColumn Find (string columnName)
{
if (String.IsNullOrEmpty(columnName)) {
throw new ArgumentNullException("columnName");
}
return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture));
}
public void AddRange (IEnumerable<AbstractColumn> items)
{
foreach (AbstractColumn item in items){
this.Add(item);
}
}
/// <summary>
/// The Culture is used for direct String Comparison
/// </summary>
public static CultureInfo Culture
{
get { return CultureInfo.CurrentCulture;}
}
}
public class SortColumnCollection: ColumnCollection
{ {
public SortColumnCollection() public SortColumnCollection()
{ {
} }
public new AbstractColumn Find (string columnName) public AbstractColumn Find (string columnName)
{ {
if (String.IsNullOrEmpty(columnName)) { if (String.IsNullOrEmpty(columnName)) {
throw new ArgumentNullException("columnName"); throw new ArgumentNullException("columnName");
@ -97,21 +58,4 @@ namespace ICSharpCode.Reporting
return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture)); return this.FirstOrDefault(x => 0 == String.Compare(x.ColumnName,columnName,true,CultureInfo.InvariantCulture));
} }
} }
public class ReportItemCollection : Collection<PrintableItem>
{
// Trick to get the inner list as List<T> (InnerList always has that type because we only use
// the parameterless constructor on Collection<T>)
private List<PrintableItem> InnerList {
get { return (List<PrintableItem>)base.Items; }
}
private void Sort(IComparer<PrintableItem> comparer)
{
InnerList.Sort(comparer);
}
}
} }

2
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/PageBuilder/Converter/DataContainerConverter.cs

@ -53,10 +53,8 @@ namespace ICSharpCode.Reporting.PageBuilder.Converter
var position = Point.Empty; var position = Point.Empty;
do { do {
collectionSource.Fill(Container.Items); collectionSource.Fill(Container.Items);
// Console.WriteLine(((BaseDataItem)Container.Items[0]).DBValue);
var itemsList = CreateConvertedList(exportContainer,position); var itemsList = CreateConvertedList(exportContainer,position);
exportContainer.ExportedItems.AddRange(itemsList); exportContainer.ExportedItems.AddRange(itemsList);
// CurrentLocation = new Point(CurrentLocation.X,CurrentLocation.Y + Container.Size.Height);
position = new Point(Container.Location.X,position.Y + Container.Size.Height); position = new Point(Container.Location.X,position.Y + Container.Size.Height);
} }
while (collectionSource.MoveNext()); while (collectionSource.MoveNext());

25
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Src/ReportingFactory.cs

@ -30,15 +30,6 @@ namespace ICSharpCode.Reporting
{ {
} }
public IReportCreator ReportCreator (ReportModel reportModel) {
if (reportModel == null)
throw new ArgumentNullException("reportModel");
IReportCreator builder = null;
builder = ReportCreatorFactory.ExporterFactory(reportModel);
return builder;
}
public IReportCreator ReportCreator (Stream stream,Type listType,IEnumerable list) public IReportCreator ReportCreator (Stream stream,Type listType,IEnumerable list)
{ {
@ -49,16 +40,26 @@ namespace ICSharpCode.Reporting
} }
internal IReportCreator ReportCreator (ReportModel reportModel) {
if (reportModel == null)
throw new ArgumentNullException("reportModel");
IReportCreator builder = null;
ReportModel = reportModel;
builder = ReportCreatorFactory.ExporterFactory(reportModel);
return builder;
}
internal IReportCreator ReportCreator (Stream stream) internal IReportCreator ReportCreator (Stream stream)
{ {
IReportModel reportModel = LoadReportModel (stream); ReportModel = LoadReportModel (stream);
IReportCreator builder = null; IReportCreator builder = null;
builder = ReportCreatorFactory.ExporterFactory(reportModel); builder = ReportCreatorFactory.ExporterFactory(ReportModel);
return builder; return builder;
} }
public ReportModel LoadReportModel (Stream stream) internal ReportModel LoadReportModel (Stream stream)
{ {
var doc = new XmlDocument(); var doc = new XmlDocument();
doc.Load(stream); doc.Load(stream);

12
src/AddIns/Misc/Reporting/ICSharpCode.Reporting/Test/ICSharpCode.Reporting.Test/src/DataSource/CollectionHandlingFixture.cs

@ -12,6 +12,7 @@ using System.Linq;
using ICSharpCode.Reporting.BaseClasses; using ICSharpCode.Reporting.BaseClasses;
using ICSharpCode.Reporting.DataManager.Listhandling; using ICSharpCode.Reporting.DataManager.Listhandling;
using ICSharpCode.Reporting.Interfaces;
using ICSharpCode.Reporting.Items; using ICSharpCode.Reporting.Items;
using NUnit.Framework; using NUnit.Framework;
@ -62,9 +63,8 @@ namespace ICSharpCode.Reporting.Test.DataSource
#region Fill #region Fill
[Test] [Test]
[Ignore]
public void TypeOfReportItemIsString () { public void TypeOfReportItemIsString () {
var ric = new ReportItemCollection(){ var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){ new BaseDataItem(){
ColumnName = "Lastname" ColumnName = "Lastname"
@ -75,7 +75,7 @@ namespace ICSharpCode.Reporting.Test.DataSource
}; };
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings()); var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind(); collectionSource.Bind();
// collectionSource.Fill(ric); collectionSource.Fill(ric);
foreach (BaseDataItem element in ric) { foreach (BaseDataItem element in ric) {
Assert.That(element.DataType,Is.EqualTo("System.String")); Assert.That(element.DataType,Is.EqualTo("System.String"));
} }
@ -83,9 +83,8 @@ namespace ICSharpCode.Reporting.Test.DataSource
[Test] [Test]
[Ignore]
public void FillReportItemCollection () { public void FillReportItemCollection () {
var ric = new ReportItemCollection(){ var ric = new System.Collections.Generic.List<IPrintableObject>(){
new BaseDataItem(){ new BaseDataItem(){
ColumnName = "Lastname" ColumnName = "Lastname"
@ -96,7 +95,7 @@ namespace ICSharpCode.Reporting.Test.DataSource
}; };
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings()); var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());
collectionSource.Bind(); collectionSource.Bind();
// collectionSource.Fill(ric); collectionSource.Fill(ric);
foreach (BaseDataItem element in ric) { foreach (BaseDataItem element in ric) {
Assert.That(element.DBValue,Is.Not.EqualTo(String.Empty)); Assert.That(element.DBValue,Is.Not.EqualTo(String.Empty));
} }
@ -131,7 +130,6 @@ namespace ICSharpCode.Reporting.Test.DataSource
#region Sort #region Sort
[Test] [Test]
public void CreateUnsortedIndex() { public void CreateUnsortedIndex() {
var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings()); var collectionSource = new CollectionSource (list,typeof(Contributor),new ReportSettings());

Loading…
Cancel
Save