26 changed files with 1138 additions and 33 deletions
@ -0,0 +1,63 @@
@@ -0,0 +1,63 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:16 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Xml.Serialization; |
||||
|
||||
namespace ICSharpCode.Reporting.BaseClasses |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AbstractColumn.
|
||||
/// </summary>
|
||||
public class AbstractColumn |
||||
{ |
||||
private string columnName; |
||||
private Type dataType; |
||||
private string dataTypeName; |
||||
|
||||
public AbstractColumn() { |
||||
this.dataType = typeof(System.String); |
||||
this.columnName = string.Empty; |
||||
} |
||||
|
||||
// public AbstractColumn(string columnName){
|
||||
// this.columnName = columnName;
|
||||
// this.dataType = typeof(System.String);
|
||||
// }
|
||||
|
||||
public AbstractColumn(string columnName, Type dataType){ |
||||
this.columnName = columnName; |
||||
this.dataType = dataType; |
||||
} |
||||
|
||||
public string ColumnName {get;set;} |
||||
|
||||
|
||||
|
||||
public string DataTypeName { |
||||
get { |
||||
return this.dataType.ToString(); |
||||
} |
||||
set { |
||||
dataTypeName = value; |
||||
this.dataType = Type.GetType(dataTypeName,true,true); |
||||
} |
||||
} |
||||
|
||||
[XmlIgnoreAttribute] |
||||
public Type DataType { |
||||
get { |
||||
return dataType; |
||||
} |
||||
set { |
||||
dataType = value; |
||||
} |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:20 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.ComponentModel; |
||||
|
||||
namespace ICSharpCode.Reporting.BaseClasses |
||||
{ |
||||
/// <summary>
|
||||
/// Description of SortColumn.
|
||||
/// </summary>
|
||||
public class SortColumn : AbstractColumn { |
||||
|
||||
private ListSortDirection sortDirection = ListSortDirection.Ascending; |
||||
private bool caseSensitive; |
||||
|
||||
|
||||
public SortColumn():this(String.Empty,ListSortDirection.Ascending,typeof(System.String),false) |
||||
{ |
||||
} |
||||
|
||||
public SortColumn(string columnName,Type type ):this(columnName,ListSortDirection.Ascending,type,false) |
||||
{ |
||||
} |
||||
|
||||
|
||||
public SortColumn(string columnName,ListSortDirection sortDirection) |
||||
:this(columnName,sortDirection,typeof(System.String),false){ |
||||
} |
||||
|
||||
|
||||
public SortColumn(string columnName, ListSortDirection sortDirection, Type type,bool caseSensitive ):base (columnName,type) |
||||
{ |
||||
this.caseSensitive = caseSensitive; |
||||
this.sortDirection = sortDirection; |
||||
} |
||||
|
||||
#region properties
|
||||
|
||||
public ListSortDirection SortDirection {get;set;} |
||||
|
||||
|
||||
public bool CaseSensitive {get;private set;} |
||||
|
||||
|
||||
#endregion
|
||||
} |
||||
} |
@ -0,0 +1,92 @@
@@ -0,0 +1,92 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:03 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Globalization; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
|
||||
namespace ICSharpCode.Reporting |
||||
{ |
||||
/// <summary>
|
||||
/// Description of Collections.
|
||||
/// </summary>
|
||||
|
||||
public class ColumnCollection: 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 new 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<SortColumn> items) |
||||
{ |
||||
foreach (SortColumn item in items){ |
||||
this.Add(item); |
||||
} |
||||
} |
||||
|
||||
|
||||
/// <summary>
|
||||
/// The Culture is used for direct String Comparison
|
||||
/// </summary>
|
||||
|
||||
// public new static CultureInfo Culture
|
||||
// {
|
||||
// get { return CultureInfo.CurrentCulture;}
|
||||
// }
|
||||
} |
||||
} |
@ -0,0 +1,89 @@
@@ -0,0 +1,89 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:09 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel; |
||||
|
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
using ICSharpCode.Reporting.DataSource; |
||||
using ICSharpCode.Reporting.Interfaces.Data; |
||||
using ICSharpCode.Reporting.Items; |
||||
|
||||
namespace ICSharpCode.Reporting.DataManager.Listhandling |
||||
{ |
||||
/// <summary>
|
||||
/// Description of CollectionHandling.
|
||||
/// </summary>
|
||||
internal class CollectionSource:IDataViewHandling |
||||
{ |
||||
|
||||
private PropertyDescriptorCollection listProperties; |
||||
private DataCollection<object> baseList; |
||||
private ReportSettings reportSettings; |
||||
|
||||
|
||||
public CollectionSource(IList list,ReportSettings reportSettings) |
||||
{ |
||||
|
||||
if (list.Count > 0) { |
||||
// firstItem = list[0];
|
||||
|
||||
var itemType = list[0].GetType(); |
||||
this.baseList = new DataCollection <object>(itemType); |
||||
this.baseList.AddRange(list); |
||||
} |
||||
this.reportSettings = reportSettings; |
||||
this.listProperties = this.baseList.GetItemProperties(null); |
||||
IndexList = new IndexList(); |
||||
} |
||||
|
||||
public int Count |
||||
{ |
||||
get { |
||||
return this.baseList.Count; |
||||
} |
||||
} |
||||
|
||||
public Collection<AbstractColumn> AvailableFields { |
||||
get { |
||||
// base.AvailableFields.Clear();
|
||||
var av = new Collection<AbstractColumn>(); |
||||
foreach (PropertyDescriptor p in this.listProperties){ |
||||
av.Add (new AbstractColumn(p.Name,p.PropertyType)); |
||||
} |
||||
return av; |
||||
} |
||||
} |
||||
|
||||
public object Current { |
||||
get { |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
|
||||
public void Sort() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public bool MoveNext() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public void Reset() |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
|
||||
public IndexList IndexList {get; private set;} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,27 @@
@@ -0,0 +1,27 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:54 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Reporting.DataSource.Comparer; |
||||
|
||||
namespace ICSharpCode.Reporting.DataManager.Listhandling |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IndexList.
|
||||
/// </summary>
|
||||
public class IndexList :List<BaseComparer> |
||||
{ |
||||
|
||||
public IndexList() |
||||
{ |
||||
} |
||||
|
||||
public int CurrentPosition {get;set;} |
||||
} |
||||
} |
@ -0,0 +1,94 @@
@@ -0,0 +1,94 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:57 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource.Comparer |
||||
{ |
||||
/// <summary>
|
||||
/// Description of BaseComparer.
|
||||
/// </summary>
|
||||
public class BaseComparer : IComparable { |
||||
|
||||
private int listIndex; |
||||
private object[] objectArray; |
||||
|
||||
ColumnCollection columnCollection; |
||||
/// <summary>
|
||||
/// Default constructor - initializes all fields to default values
|
||||
/// </summary>
|
||||
|
||||
public BaseComparer(ColumnCollection columnCollection , int listIndex, object[] values) { |
||||
this.columnCollection = columnCollection; |
||||
this.listIndex = listIndex; |
||||
this.objectArray = values; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Interface method from IComparable
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Interface method from IComparable
|
||||
///
|
||||
/// </remarks>
|
||||
/// <param name='obj'>a <see cref="BaseComparer"></see></param>
|
||||
public virtual int CompareTo(object obj) { |
||||
return 0; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Ausgeben der Werte als Pseudo-CSV
|
||||
/// </summary>
|
||||
public override string ToString() |
||||
{ |
||||
System.Text.StringBuilder builder = new System.Text.StringBuilder(); |
||||
builder.AppendFormat("{0};", this.listIndex); |
||||
foreach (object value in objectArray) |
||||
{ |
||||
if (value == null || value == DBNull.Value) |
||||
{ |
||||
builder.AppendFormat("<NULL>"); |
||||
} |
||||
else if (value.GetType() == typeof(string)) |
||||
{ |
||||
builder.AppendFormat("\"{0}\"", (string)value); |
||||
} |
||||
else if (value is IFormattable) |
||||
{ |
||||
builder.AppendFormat("{0}", ((IFormattable)value).ToString("g", System.Globalization.CultureInfo.InvariantCulture)); |
||||
} |
||||
else |
||||
{ |
||||
builder.AppendFormat("[{0}]", value.ToString()); |
||||
} |
||||
builder.Append(';'); |
||||
} |
||||
return builder.ToString(); |
||||
} |
||||
|
||||
|
||||
public int ListIndex { |
||||
get { |
||||
return listIndex; |
||||
} |
||||
} |
||||
|
||||
public object[] ObjectArray { |
||||
get { |
||||
return objectArray; |
||||
} |
||||
} |
||||
|
||||
|
||||
public ColumnCollection ColumnCollection { |
||||
get { |
||||
return columnCollection; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,203 @@
@@ -0,0 +1,203 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 17:55 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.ComponentModel; |
||||
using System.Diagnostics; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource |
||||
{ |
||||
/// <summary>
|
||||
/// Description of DataCollection.
|
||||
/// </summary>
|
||||
internal class DataCollection<T> : IList<T>,ITypedList |
||||
{ |
||||
Collection<T> list = new Collection<T>(); |
||||
Type elementType; |
||||
|
||||
public DataCollection(Type elementType) |
||||
{ |
||||
this.elementType = elementType; |
||||
} |
||||
|
||||
public T this[int index] |
||||
{ |
||||
get { |
||||
return list[index]; |
||||
} |
||||
set { |
||||
T oldValue = list[index]; |
||||
if (!object.Equals(oldValue, value)) { |
||||
list[index] = value; |
||||
} |
||||
} |
||||
} |
||||
|
||||
public int Count |
||||
{ |
||||
[DebuggerStepThrough] |
||||
get { |
||||
return list.Count; |
||||
} |
||||
} |
||||
|
||||
public bool IsReadOnly |
||||
{ |
||||
get { |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
public int IndexOf(T item) |
||||
{ |
||||
return list.IndexOf(item); |
||||
} |
||||
|
||||
public void Insert(int index, T item) |
||||
{ |
||||
list.Insert(index, item); |
||||
} |
||||
|
||||
public void RemoveAt(int index) |
||||
{ |
||||
list.RemoveAt(index); |
||||
} |
||||
|
||||
public void Add(T item) |
||||
{ |
||||
list.Add(item); |
||||
} |
||||
|
||||
|
||||
public void AddRange(IList range) |
||||
{ |
||||
foreach(T t in range) { |
||||
Add(t); |
||||
} |
||||
} |
||||
|
||||
|
||||
public void Clear(){ |
||||
list = new Collection<T>(); |
||||
} |
||||
|
||||
public bool Contains(T item) |
||||
{ |
||||
return list.Contains(item); |
||||
} |
||||
|
||||
public void CopyTo(T[] array, int arrayIndex) |
||||
{ |
||||
list.CopyTo(array, arrayIndex); |
||||
} |
||||
|
||||
public bool Remove(T item) |
||||
{ |
||||
if (list.Remove(item)) { |
||||
return true; |
||||
} |
||||
return false; |
||||
} |
||||
|
||||
#region ITypedList Member
|
||||
|
||||
public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors){ |
||||
if (listAccessors != null && listAccessors.Length > 0){ |
||||
Type t = this.elementType; |
||||
|
||||
for(int i = 0; i < listAccessors.Length; i++){ |
||||
PropertyDescriptor pd = listAccessors[i]; |
||||
t = (Type) PropertyTypeHash.Instance[t, pd.Name]; |
||||
} |
||||
// if t is null an empty list will be generated
|
||||
return ExtendedTypeDescriptor.GetProperties(t); |
||||
} |
||||
return ExtendedTypeDescriptor.GetProperties(elementType); |
||||
} |
||||
|
||||
|
||||
public string GetListName(PropertyDescriptor[] listAccessors){ |
||||
return elementType.Name; |
||||
} |
||||
|
||||
public static Type GetElementType(IList list, Type parentType, string propertyName) |
||||
{ |
||||
DataCollection<T> al = null; |
||||
object element = null; |
||||
al = CheckForArrayList(list); |
||||
if (al == null) |
||||
{ |
||||
if (list.Count > 0) |
||||
{ |
||||
element = list[0]; |
||||
} |
||||
} |
||||
if (al == null && element == null) |
||||
{ |
||||
PropertyInfo pi = parentType.GetProperty(propertyName); |
||||
if (pi != null) |
||||
{ |
||||
object parentObject = null; |
||||
try |
||||
{ |
||||
parentObject = Activator.CreateInstance(parentType); |
||||
} |
||||
catch(Exception) {} |
||||
if (parentObject != null) |
||||
{ |
||||
list = pi.GetValue(parentObject, null) as IList; |
||||
al = CheckForArrayList(list); |
||||
} |
||||
} |
||||
} |
||||
if (al != null) |
||||
{ |
||||
return al.elementType; |
||||
} |
||||
else if (element != null) |
||||
{ |
||||
return element.GetType(); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
private static DataCollection<T> CheckForArrayList(object l) |
||||
{ |
||||
IList list = l as IList; |
||||
if (list == null) |
||||
return null; |
||||
if (list.GetType().FullName == "System.Collections.ArrayList+ReadOnlyArrayList") |
||||
{ |
||||
FieldInfo fi = list.GetType().GetField("_list", BindingFlags.NonPublic | BindingFlags.Instance); |
||||
if (fi != null) |
||||
{ |
||||
list = (IList) fi.GetValue(list); |
||||
} |
||||
} |
||||
return list as DataCollection<T>; |
||||
} |
||||
#endregion
|
||||
|
||||
|
||||
[DebuggerStepThrough] |
||||
public IEnumerator<T> GetEnumerator() |
||||
{ |
||||
return list.GetEnumerator(); |
||||
} |
||||
|
||||
[DebuggerStepThrough] |
||||
System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() |
||||
{ |
||||
return list.GetEnumerator(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,95 @@
@@ -0,0 +1,95 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 18:05 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ExtendedPropertyDescriptor.
|
||||
/// </summary>
|
||||
internal class ExtendedPropertyDescriptor : PropertyDescriptor |
||||
{ |
||||
|
||||
Type componentType; |
||||
Type propertyType; |
||||
PropertyInfo prop; |
||||
|
||||
public ExtendedPropertyDescriptor (string name, Type componentType, Type propertyType) |
||||
: base (name, null) |
||||
{ |
||||
this.componentType = componentType; |
||||
this.propertyType = propertyType; |
||||
} |
||||
|
||||
|
||||
public override object GetValue (object component) |
||||
{ |
||||
if (!componentType.IsAssignableFrom(component.GetType())){ |
||||
return null; |
||||
} |
||||
|
||||
if (prop == null) { |
||||
prop = componentType.GetProperty (Name); |
||||
} |
||||
|
||||
object obj = prop.GetValue (component, null); |
||||
if (obj != null) { |
||||
if (obj is IList){ |
||||
PropertyTypeHash.Instance[componentType, Name] = DataCollection<object>.GetElementType((IList)obj, componentType, Name); |
||||
} |
||||
} |
||||
return obj; |
||||
} |
||||
|
||||
|
||||
public override void SetValue(object component, object value) |
||||
{ |
||||
if (IsReadOnly){ |
||||
return; |
||||
} |
||||
if (prop == null){ |
||||
prop = componentType.GetProperty (Name); |
||||
} |
||||
prop.SetValue (component, value, null); |
||||
} |
||||
|
||||
public override void ResetValue(object component) |
||||
{ |
||||
return; |
||||
} |
||||
|
||||
public override bool CanResetValue(object component) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public override bool ShouldSerializeValue(object component) |
||||
{ |
||||
return false; |
||||
} |
||||
|
||||
public override Type ComponentType |
||||
{ |
||||
get { return componentType; } |
||||
} |
||||
|
||||
public override bool IsReadOnly |
||||
{ |
||||
get { return false; } |
||||
} |
||||
|
||||
public override Type PropertyType |
||||
{ |
||||
get { return propertyType; } |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,65 @@
@@ -0,0 +1,65 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 17:59 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.ComponentModel; |
||||
using System.Reflection; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ExtendedTypeDescriptor.
|
||||
/// </summary>
|
||||
internal class ExtendedTypeDescriptor |
||||
{ |
||||
private static Hashtable collections = new Hashtable(); |
||||
|
||||
private static bool IsAllowedProperty(string name) |
||||
{ |
||||
return true; // alle erlaubt
|
||||
} |
||||
|
||||
|
||||
public static PropertyDescriptorCollection GetProperties(Type memberType) |
||||
{ |
||||
if (memberType == null) |
||||
return PropertyDescriptorCollection.Empty; |
||||
|
||||
PropertyDescriptorCollection pdc; |
||||
if ((pdc = (PropertyDescriptorCollection) collections[memberType]) != null) |
||||
return (pdc); |
||||
|
||||
PropertyInfo[] allProps = memberType.GetProperties(); |
||||
int l = allProps.Length; |
||||
for (int i = 0; i < allProps.Length; i++) |
||||
{ |
||||
PropertyInfo pi = allProps[i]; |
||||
if (!IsAllowedProperty(pi.Name)) |
||||
{ |
||||
allProps[i] = null; |
||||
l--; |
||||
} |
||||
} |
||||
|
||||
PropertyDescriptor[] descriptors = new PropertyDescriptor[l]; |
||||
|
||||
int j = 0; |
||||
foreach(PropertyInfo pinfo in allProps) |
||||
{ |
||||
if (pinfo != null) |
||||
{ |
||||
descriptors[j++] = new ExtendedPropertyDescriptor(pinfo.Name, memberType, pinfo.PropertyType); |
||||
} |
||||
} |
||||
PropertyDescriptorCollection result = new PropertyDescriptorCollection(descriptors); |
||||
collections.Add(memberType, result); |
||||
return result; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,53 @@
@@ -0,0 +1,53 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 18:02 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
|
||||
namespace ICSharpCode.Reporting.DataSource |
||||
{ |
||||
/// <summary>
|
||||
/// Description of PropertyTypeHash.
|
||||
/// </summary>
|
||||
internal class PropertyTypeHash |
||||
{ |
||||
static PropertyTypeHash instance = new PropertyTypeHash(); |
||||
|
||||
static public PropertyTypeHash Instance |
||||
{ |
||||
get { return instance; } |
||||
} |
||||
|
||||
Hashtable types = new Hashtable(); |
||||
|
||||
private static string MakeIndex(Type t, string name) |
||||
{ |
||||
return t.FullName + '.' + name; |
||||
} |
||||
|
||||
public object this[Type type, string fieldName] |
||||
{ |
||||
get |
||||
{ |
||||
return types[MakeIndex(type, fieldName)]; |
||||
} |
||||
set |
||||
{ |
||||
if (value == null) |
||||
return; |
||||
string key = MakeIndex(type, fieldName); |
||||
if (!types.Contains(key)) |
||||
types.Add(key, value); |
||||
} |
||||
} |
||||
|
||||
private PropertyTypeHash() |
||||
{ |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,49 @@
@@ -0,0 +1,49 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 21.05.2013 |
||||
* Time: 20:35 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections; |
||||
using System.Collections.ObjectModel; |
||||
|
||||
using ICSharpCode.Reporting.BaseClasses; |
||||
using ICSharpCode.Reporting.DataManager.Listhandling; |
||||
|
||||
namespace ICSharpCode.Reporting.Interfaces.Data |
||||
{ |
||||
/// <summary>
|
||||
/// Description of IDataViewHandling.
|
||||
/// </summary>
|
||||
public interface IDataViewHandling:IEnumerator{ |
||||
|
||||
void Sort (); |
||||
|
||||
// void Group();
|
||||
|
||||
// void Bind();
|
||||
|
||||
// void Fill (int position,ReportItemCollection collection);
|
||||
|
||||
//rausnehmen
|
||||
// void Fill (IDataItem item);
|
||||
|
||||
IndexList IndexList {get;} |
||||
|
||||
// object CurrentFromPosition(int pos);
|
||||
|
||||
// CurrentItemsCollection FillDataRow();
|
||||
// CurrentItemsCollection FillDataRow(int pos);
|
||||
//
|
||||
Collection<AbstractColumn> AvailableFields {get;} |
||||
|
||||
int Count {get;} |
||||
|
||||
// int CurrentPosition {get;set;}
|
||||
|
||||
// IExpressionEvaluatorFacade ExpressionEvaluator {get;}
|
||||
} |
||||
} |
@ -0,0 +1,57 @@
@@ -0,0 +1,57 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 18:15 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
using ICSharpCode.Reporting.DataManager.Listhandling; |
||||
using ICSharpCode.Reporting.DataSource; |
||||
using ICSharpCode.Reporting.Items; |
||||
using NUnit.Framework; |
||||
|
||||
namespace ICSharpCode.Reporting.Test.DataSource |
||||
{ |
||||
[TestFixture] |
||||
public class CollectionHandlingFixture |
||||
{ |
||||
|
||||
private ContributorCollection list; |
||||
|
||||
[Test] |
||||
public void CanInitDataCollection() |
||||
{ |
||||
var collectionSource = new CollectionSource (list,new ReportSettings()); |
||||
Assert.That(collectionSource,Is.Not.Null); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void CollectionCountIsEqualToListCount() { |
||||
var collectionSource = new CollectionSource (list,new ReportSettings()); |
||||
Assert.That(collectionSource.Count,Is.EqualTo(list.Count)); |
||||
} |
||||
|
||||
|
||||
[Test] |
||||
public void AvailableFieldsEqualContibutorsPropertyCount() { |
||||
var collectionSource = new CollectionSource (list,new ReportSettings()); |
||||
Assert.That(collectionSource.AvailableFields.Count,Is.EqualTo(7)); |
||||
} |
||||
|
||||
|
||||
|
||||
//http://stackoverflow.com/questions/5378293/simplest-way-to-filter-generic-list
|
||||
//http://stackoverflow.com/questions/5378293/simplest-way-to-filter-generic-list
|
||||
//http://netmatze.wordpress.com/2012/06/21/implementing-a-generic-iequalitycomparer-and-icomparer-class/
|
||||
// http://blog.velir.com/index.php/2011/02/17/ilistt-sorting-a-better-way/
|
||||
[SetUp] |
||||
public void CreateList() { |
||||
var contributorList = new ContributorsList(); |
||||
list = contributorList.ContributorCollection; |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,132 @@
@@ -0,0 +1,132 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Peter Forstmeier |
||||
* Date: 20.05.2013 |
||||
* Time: 18:09 |
||||
* |
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers. |
||||
*/ |
||||
using System; |
||||
using System.Collections.Generic; |
||||
|
||||
namespace ICSharpCode.Reporting.Test.DataSource |
||||
{ |
||||
/// <summary>
|
||||
/// Description of ContributorsList.
|
||||
/// </summary>
|
||||
public class ContributorsList |
||||
{ |
||||
ContributorCollection contributorCollection; |
||||
|
||||
public ContributorsList() |
||||
{ |
||||
this.contributorCollection = CreateContributorsList(); |
||||
} |
||||
|
||||
public ContributorCollection ContributorCollection { |
||||
get { return contributorCollection; } |
||||
} |
||||
|
||||
private ContributorCollection CreateContributorsList () { |
||||
|
||||
DateTime d1 = new DateTime(2000,11,11); |
||||
DateTime d2 = new DateTime(2000,01,01); |
||||
DateTime d3 = new DateTime(2000,12,24); |
||||
|
||||
ContributorCollection list = new ContributorCollection(); |
||||
|
||||
list.Add(new Contributor("Christoph","Wille","Senior Project Wrangler",17,new DateTime(1960,12,8),"F")); |
||||
list.Add(new Contributor("Bernhard","Spuida","Senior Project Wrangler",25,new DateTime(1962,2,24),"D")); |
||||
|
||||
|
||||
list.Add(new Contributor("Daniel","Grunwald","Technical Lead",12,d1,"F")); |
||||
|
||||
list.Add(new Contributor("Matt","Ward","NUnit",7,d1,"F")); |
||||
list.Add(new Contributor("David","Srbecky","Debugger",1,d1,"C")); |
||||
list.Add(new Contributor("Peter","Forstmeier","SharpDevelop.Reports",7,d1,"D")); |
||||
|
||||
list.Add(new Contributor("Alexander","Zeitler","SharpDevelop.Reports",3,d2,"D")); |
||||
list.Add(new Contributor("Markus","Palme","Prg.",6,d2,"R")); |
||||
list.Add(new Contributor("Georg","Brandl","Prg.",5,d2,"R")); |
||||
list.Add(new Contributor("Roman","Taranchenko","",2,d2,"U")); |
||||
list.Add(new Contributor("Denis","Erchoff","",13,d2,"U")); |
||||
|
||||
list.Add(new Contributor("Ifko","Kovacka","",31,d3,"A")); |
||||
list.Add(new Contributor("Nathan","Allen","",5,d3,"A")); |
||||
list.Add(new Contributor("Dickon","Field","DBTools",10,d3,"U")); |
||||
|
||||
list.Add(new Contributor("Troy","Simpson","Prg.",9,d3,"C")); |
||||
list.Add(new Contributor("David","Alpert","Prg.",6,d3,"C")); |
||||
return list; |
||||
} |
||||
} |
||||
|
||||
public class ContributorCollection: List<Contributor> |
||||
{ |
||||
} |
||||
|
||||
public class Contributor { |
||||
string last; |
||||
string first; |
||||
string job; |
||||
|
||||
int randomInt; |
||||
DateTime randomDate; |
||||
|
||||
public Contributor(string last, string first,string job,int randomInt,DateTime randomDate,string groupItem) |
||||
{ |
||||
this.last = last; |
||||
this.first = first; |
||||
this.job = job; |
||||
this.randomDate = randomDate; |
||||
this.randomInt = randomInt; |
||||
this.GroupItem = groupItem; |
||||
} |
||||
|
||||
|
||||
public string Last { |
||||
get { |
||||
return last; |
||||
} |
||||
|
||||
} |
||||
|
||||
public string First { |
||||
get { |
||||
return first; |
||||
} |
||||
|
||||
} |
||||
|
||||
public string Job { |
||||
get { |
||||
return job; |
||||
} |
||||
} |
||||
|
||||
public int RandomInt { |
||||
get { return randomInt; } |
||||
} |
||||
|
||||
|
||||
public DateTime RandomDate { |
||||
get { return randomDate; } |
||||
} |
||||
|
||||
public string GroupItem {get; set;} |
||||
|
||||
public MyDummyClass DummyClass {get;set;} |
||||
|
||||
} |
||||
|
||||
public class MyDummyClass |
||||
{ |
||||
public MyDummyClass() |
||||
{ |
||||
|
||||
} |
||||
|
||||
public string DummyString {get;set;} |
||||
public int DummyInt {get;set;} |
||||
} |
||||
} |
Loading…
Reference in new issue