TypedColumnBasedataTypeBindValue(FuncdataType) Method
Binds the value of this column to the specified expression
Namespace: Firefly.Box.Data.AdvancedAssembly: Firefly.Box (in Firefly.Box.dll) Version: debug-master-v:33791
public TypedColumnBase<dataType> BindValue(
Func<dataType> expression
)
Public Function BindValue (
expression As Func(Of dataType)
) As TypedColumnBase(Of dataType)
member BindValue :
expression : Func<'dataType> -> TypedColumnBase<'dataType>
- expression FuncdataType
TypedColumnBasedataType
The expression specified will determine the column's value in one of the following scenarios:
- The column is bound to an entity, and a new row is created
- The column is NOT bound to an entity, and a row is entered
- One of the expression's elements change, acording to the reevaluation engine. For more information see Columns
This example demonstrates the usage of ColumnsCollection
This example is in the form of Unit Tests. It references the NUnit framework. This framework can be downloaded from
www.NUnit.org. For more information about unit testing visit:
www.NUnit.org.
using System;
using System.Collections.Generic;
using System.Text;
using Firefly.Box.Data;
using NUnit.Framework;
using Firefly.Box;
using Firefly.Box.Testing;
namespace TestFirefly.Box.Documentation
{
[TestFixture]
public class ColumnsCollection
{
[Test]
public void BasicReevaluation()
{
var bp = new BusinessProcess();
NumberColumn a = new NumberColumn(),
b = new NumberColumn();
bp.Columns.Add(a, b);
b.BindValue(() => a + 5);
bp.ForFirstRow(() =>
{
a.ShouldBe(0);
b.ShouldBe(5);
a.Value = 6;
a.ShouldBe(6);
b.ShouldBe(11);
});
}
[Test]
public void ReevaluationIsNotDoneBeforeAnyRowWasEntered()
{
var bp = new BusinessProcess();
NumberColumn a = new NumberColumn(),
b = new NumberColumn();
bp.Columns.Add(a, b);
b.BindValue(() => a + 5);
bp.Start += () =>
{
a.ShouldBe(0);
b.ShouldBe(0); //Because a row was not entered, and no value was set,
//the reevaluation of b was not performed
};
bp.ForFirstRow(() =>
{
a.ShouldBe(0);
b.ShouldBe(5);
a.Value = 6;
a.ShouldBe(6);
b.ShouldBe(11);
});
}
}
}