Gets a value of a data object property

Namespace: Dapfor.Wpf.Data
Assembly: Dapfor.Wpf (in Dapfor.Wpf.dll) Version: 4.1.0.26317 (4.1.0.26317)

Syntax

C#
public sealed class Getter<T> : IGetter
Visual Basic
Public NotInheritable Class Getter(Of T)
	Implements IGetter
Visual C++
generic<typename T>
public ref class Getter sealed : IGetter
F#
[<SealedAttribute>]
type Getter<'T> =  
    class
        interface IGetter
    end

Type Parameters

T
Type of a value, returned by property of data object

Remarks

In some cases getting values of data objects through the IDataField interface may be a costly operation because it occurs through the reflection. To accelerate the values getting, the data objects may implement IGetAccelerator interface. In this case the values are returned through the delegating mechanism and not through the reflection.

Examples

 Copy imageCopy
public class TestClass : IGetAccelerator
{
    private int intValue;
    private double doubleValue;

    //Some property that returns int value
    public int IntValue
    {
        get { return intValue; }
        set { intValue = value; }
    }


    public double DoubleValue
    {
        get { return doubleValue; }
        set { doubleValue = value; }
    }

    //IGetAccelerator implementation.
    public IGetter GetGetter(IDataField field)
    {
        switch (field.Id)
        {
            //This implementation returns a delegate that calls IntValue property
            case "IntValue": 
                return new Getter<int>(delegate { return IntValue; });

            //This implementation creates a new object of the ValueGetter type which keeps a value, returned by the DoubleValue property call
            case "DoubleValue": 
                return new ValueGetter(DoubleValue);
        }
        return null;
    }
}

//Demonstrates how the data object can be added to the grid
public void HowToUseExample(GridControl grid)
{
    grid.Rows.Add(new TestClass());
}

Inheritance Hierarchy

System..::..Object
  Dapfor.Wpf.Data..::..Getter<(Of <(<'T>)>)>

See Also