IBcfTransactionFactory Interface |
[This is preliminary documentation and is subject to change.]
Namespace: CalculationWorks.BusinessModel
The IBcfTransactionFactory type exposes the following members.
Name | Description | |
---|---|---|
EnforceConstraints |
Gets or sets the default value for transaction builders EnforceConstraints-property.
| |
MicroTransactionMode |
Gets or sets the default value for transaction builders MicroTransactionMode-property.
| |
TriggersEnabled |
Gets or sets the default value for transaction builders TriggersEnabled-property.
|
Name | Description | |
---|---|---|
CreateTransaction |
Creates and returns a new transaction instance.
| |
CreateTransactionBuilder |
Creates and returns a new transaction builder instance.
| |
CreateTransactionInfoObject |
Infrastructure. The member supports the infrastructure and is not intended to be used directly from your code.
| |
CreateTransactionName |
Creates a name for the BcfTransaction.
|
using System; using CalculationWorks.BusinessModel; using CalculationWorks.BusinessModel.Design; using CalculationWorks.BusinessModel.UndoRedo; namespace MyNamespace { public class MyTransactionBuilder : BcfTransactionBuilder { /// <summary> /// An additional comment /// </summary> public string Comment { get; set; } } public class MyTransactionInfo : IBcfTransactionInfo { /// <summary> /// The <see cref="IBcfTransactionInfo.Name"/> implementation. /// </summary> public string Name { get; set; } /// <summary> /// The <see cref="MyTransactionBuilder.Comment">additional comment from builder</see>. /// </summary> public string Comment { get; set; } /// <summary> /// Date and time when transaction was committed. /// </summary> public DateTime? CommittedAt { get; set; } } public class MyTransaction : BcfTransaction { public MyTransaction([NotNull] BcfDataSet dataSet, [NotNull] BcfTransactionBuilder builder) : base(dataSet, builder) { // Info is not initialized for subtransactions if(IsSubTransaction) Info = DataSet.TransactionFactory.CreateTransactionInfoObject(); Comment = ((MyTransactionBuilder)builder).Comment; } public MyTransactionInfo MyInfo { get { return (MyTransactionInfo)Info; } } /// <summary> /// The <see cref="MyTransactionBuilder.Comment">additional comment from builder</see>. /// </summary> public string Comment { get { return MyInfo.Comment; } set { MyInfo.Comment = value; } } /// <summary> /// Date and time when transaction was committed. /// </summary> public DateTime? CommittedAt { get { return MyInfo.CommittedAt; } } /// <summary> /// If using file-based undo here is the last chance for updates on <see cref="MyInfo"/> before it is serialized. /// </summary> protected override void OnBeforeCommitComplete() { MyInfo.CommittedAt = DateTime.Now; } } public class MyTransactionFactory : BcfTransactionFactoryBase<MyTransaction, MyTransactionInfo, MyTransactionBuilder> { public MyTransactionFactory([NotNull] BcfDataSet dataSet) : base(dataSet) { // changing default because it sucks EnforceConstraints = false; } public override MyTransaction CreateTransaction(BcfTransactionBuilder transactionBuilder) { return new MyTransaction(DataSet, transactionBuilder); } } // Handwritten part for BCF-Editor generated partial DataSetSetup-class. partial class MyDataSetSetup { // BCF-Editor generates "partial void Initialized();" we can implement in same cs-project the generated DataSetSetup-class resides. partial void Initialized() { CreateTransactionFactory = dataSet => new MyTransactionFactory(dataSet); } } }