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
Afficher le fichier Open project: soywiz/cspspemu

Méthodes publiques

Méthode 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.

Méthodes protégées

Méthode 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 méthode

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

DisplayNameToColumnTitle() protected méthode

Convert a property name to a displayable title.
protected DisplayNameToColumnTitle ( string displayName ) : string
displayName string
Résultat string

GenerateAndReplaceColumns() public méthode

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].
Résultat void

GenerateChildrenDelegates() protected méthode

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

GenerateColumns() public static méthode

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
Résultat IList

GenerateColumns() public méthode

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].
Résultat IList

GenerateColumns() public static méthode

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.
Résultat void

GenerateColumns() public static méthode

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].
Résultat void

GenerateColumns() public static méthode

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.
Résultat void

GenerateColumns() public static méthode

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].
Résultat void

MakeColumn() protected méthode

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

MakeColumn() protected méthode

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
Résultat OLVColumn

MakeColumnFromAttribute() protected méthode

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
Résultat OLVColumn

MakeColumnFromPropertyDescriptor() public méthode

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

MakeColumnFromPropertyInfo() protected méthode

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

PostCreateColumns() public méthode

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

ReplaceColumns() protected méthode

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
Résultat void

TryGenerateChildrenDelegates() protected méthode

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
Résultat void