C# Class BrightIdeasSoftware.Generator

The Generator class provides methods to dynamically create columns for an ObjectListView based on the characteristics of a given collection of model objects.

For a given type, a Generator can create columns to match the public properties of that type. The generator can consider all public properties or only those public properties marked with [OLVColumn] attribute.

Inheritance: IGenerator
Datei anzeigen Open project: soywiz/cspspemu

Public Methods

Method Description
GenerateAndReplaceColumns ( ObjectListView olv, Type type, bool allProperties ) : void

Generate columns into the given ObjectListView that come from the given model object type.

GenerateColumns ( Type type ) : IList

Generate a list of OLVColumns based on the public properties of the given type that have a OLVColumn attribute.

GenerateColumns ( Type type, bool allProperties ) : IList

Generate a list of OLVColumns based on the attributes of the given type If allProperties to true, all public properties will have a matching column generated. If allProperties is false, only properties that have a OLVColumn attribute will have a column generated.

GenerateColumns ( ObjectListView olv, IEnumerable enumerable ) : void

Replace all columns of the given ObjectListView with columns generated from the first member of the given enumerable. If the enumerable is empty or null, the ObjectListView will be cleared.

GenerateColumns ( ObjectListView olv, IEnumerable enumerable, bool allProperties ) : void

Replace all columns of the given ObjectListView with columns generated from the first member of the given enumerable. If the enumerable is empty or null, the ObjectListView will be cleared.

GenerateColumns ( ObjectListView olv, Type type ) : void

Generate columns into the given ObjectListView that come from the public properties of the given model object type.

GenerateColumns ( ObjectListView olv, Type type, bool allProperties ) : void

Generate columns into the given ObjectListView that come from the public properties of the given model object type.

MakeColumnFromPropertyDescriptor ( PropertyDescriptor pd ) : OLVColumn

Make a column from the given PropertyDescriptor

PostCreateColumns ( ObjectListView olv ) : void

Post process columns after creating them and adding them to the AllColumns collection.

Protected Methods

Method Description
ConfigurePossibleBooleanColumn ( OLVColumn column, Type propertyType ) : void

Configure the given column to show a checkbox if appropriate

DisplayNameToColumnTitle ( string displayName ) : string

Convert a property name to a displayable title.

GenerateChildrenDelegates ( TreeListView tlv, PropertyInfo pinfo ) : void

Generate CanExpand and ChildrenGetter delegates from the given property.

MakeColumn ( string aspectName, string title, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn

Create a column.

MakeColumn ( string aspectName, string title, bool editable, Type propertyType, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn
MakeColumnFromAttribute ( PropertyInfo pinfo, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn

Create a column from the given PropertyInfo and OLVColumn attribute

MakeColumnFromPropertyInfo ( PropertyInfo pinfo ) : OLVColumn

Make a column from the given PropertyInfo

ReplaceColumns ( ObjectListView olv, IList columns ) : void

Replace all the columns in the given listview with the given list of columns.

TryGenerateChildrenDelegates ( TreeListView tlv, Type type ) : void

If this given type has an property marked with [OLVChildren], make delegates that will traverse that property as the children of an instance of the model

Method Details

ConfigurePossibleBooleanColumn() protected method

Configure the given column to show a checkbox if appropriate
protected ConfigurePossibleBooleanColumn ( OLVColumn column, Type propertyType ) : void
column OLVColumn
propertyType System.Type
return void

DisplayNameToColumnTitle() protected method

Convert a property name to a displayable title.
protected DisplayNameToColumnTitle ( string displayName ) : string
displayName string
return string

GenerateAndReplaceColumns() public method

Generate columns into the given ObjectListView that come from the given model object type.
public GenerateAndReplaceColumns ( ObjectListView olv, Type type, bool allProperties ) : void
olv ObjectListView The ObjectListView to modify
type System.Type The model type whose attributes will be considered.
allProperties bool Will columns be generated for properties that are not marked with [OLVColumn].
return void

GenerateChildrenDelegates() protected method

Generate CanExpand and ChildrenGetter delegates from the given property.
protected GenerateChildrenDelegates ( TreeListView tlv, PropertyInfo pinfo ) : void
tlv TreeListView
pinfo System.Reflection.PropertyInfo
return void

GenerateColumns() public static method

Generate a list of OLVColumns based on the public properties of the given type that have a OLVColumn attribute.
public static GenerateColumns ( Type type ) : IList
type System.Type
return IList

GenerateColumns() public method

Generate a list of OLVColumns based on the attributes of the given type If allProperties to true, all public properties will have a matching column generated. If allProperties is false, only properties that have a OLVColumn attribute will have a column generated.
public GenerateColumns ( Type type, bool allProperties ) : IList
type System.Type
allProperties bool Will columns be generated for properties that are not marked with [OLVColumn].
return IList

GenerateColumns() public static method

Replace all columns of the given ObjectListView with columns generated from the first member of the given enumerable. If the enumerable is empty or null, the ObjectListView will be cleared.
public static GenerateColumns ( ObjectListView olv, IEnumerable enumerable ) : void
olv ObjectListView The ObjectListView to modify
enumerable IEnumerable The collection whose first element will be used to generate columns.
return void

GenerateColumns() public static method

Replace all columns of the given ObjectListView with columns generated from the first member of the given enumerable. If the enumerable is empty or null, the ObjectListView will be cleared.
public static GenerateColumns ( ObjectListView olv, IEnumerable enumerable, bool allProperties ) : void
olv ObjectListView The ObjectListView to modify
enumerable IEnumerable The collection whose first element will be used to generate columns.
allProperties bool Will columns be generated for properties that are not marked with [OLVColumn].
return void

GenerateColumns() public static method

Generate columns into the given ObjectListView that come from the public properties of the given model object type.
public static GenerateColumns ( ObjectListView olv, Type type ) : void
olv ObjectListView The ObjectListView to modify
type System.Type The model type whose attributes will be considered.
return void

GenerateColumns() public static method

Generate columns into the given ObjectListView that come from the public properties of the given model object type.
public static GenerateColumns ( ObjectListView olv, Type type, bool allProperties ) : void
olv ObjectListView The ObjectListView to modify
type System.Type The model type whose attributes will be considered.
allProperties bool Will columns be generated for properties that are not marked with [OLVColumn].
return void

MakeColumn() protected method

Create a column.
protected MakeColumn ( string aspectName, string title, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn
aspectName string
title string
attr BrightIdeasSoftware.OLVColumnAttribute
return OLVColumn

MakeColumn() protected method

protected MakeColumn ( string aspectName, string title, bool editable, Type propertyType, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn
aspectName string
title string
editable bool
propertyType System.Type
attr BrightIdeasSoftware.OLVColumnAttribute
return OLVColumn

MakeColumnFromAttribute() protected method

Create a column from the given PropertyInfo and OLVColumn attribute
protected MakeColumnFromAttribute ( PropertyInfo pinfo, BrightIdeasSoftware.OLVColumnAttribute attr ) : OLVColumn
pinfo System.Reflection.PropertyInfo
attr BrightIdeasSoftware.OLVColumnAttribute
return OLVColumn

MakeColumnFromPropertyDescriptor() public method

Make a column from the given PropertyDescriptor
public MakeColumnFromPropertyDescriptor ( PropertyDescriptor pd ) : OLVColumn
pd System.ComponentModel.PropertyDescriptor
return OLVColumn

MakeColumnFromPropertyInfo() protected method

Make a column from the given PropertyInfo
protected MakeColumnFromPropertyInfo ( PropertyInfo pinfo ) : OLVColumn
pinfo System.Reflection.PropertyInfo
return OLVColumn

PostCreateColumns() public method

Post process columns after creating them and adding them to the AllColumns collection.
public PostCreateColumns ( ObjectListView olv ) : void
olv ObjectListView
return void

ReplaceColumns() protected method

Replace all the columns in the given listview with the given list of columns.
protected ReplaceColumns ( ObjectListView olv, IList columns ) : void
olv ObjectListView
columns IList
return void

TryGenerateChildrenDelegates() protected method

If this given type has an property marked with [OLVChildren], make delegates that will traverse that property as the children of an instance of the model
protected TryGenerateChildrenDelegates ( TreeListView tlv, Type type ) : void
tlv TreeListView
type System.Type
return void