Click here to Skip to main content
15,896,063 members
Articles / Programming Languages / Visual Basic

Transactional Objects in VB.NET

Rate me:
Please Sign up or sign in to vote.
2.14/5 (6 votes)
18 Oct 20044 min read 70.5K   776   24  
An article on how to easily return objects to their prior state after editing.
'***Header************************************************************************************
'
'       Name        - TransactionalAttribute 
'       Description - This is an Attribute class that can be used to flag fields/properties
'                     as entering into the transaction. By default all fields (in a deep tran) 
'                     and all readable/writeable properties (in a shallow tran) automaticaly
'                     enter into a trnasaction.
'                     By using this attribute we can explicitly declare that a a field/prop
'                     forms part of the transaction, or mark it as not being part of the
'                     Transaction. Example:
'
'                     <Transaction.Transactional(True)>  Private Var as String
'                     <Transaction.Transactional(False)> Private Var2 as String
'                     Private Var3 as String
'
'                     In this example Var and Var3 will enter into the transaction while
'                     Var2 will not
'
'       Date        - 18 Oct 2004
'       Author      - Tom Mulledy (tmulledy[AT]stab-room.com
'
'       Modification Log
'       -------------------------------------------------------------------------------
'       ModDate     -
'       ModBy       -
'       ModDesc     -
'
'********************************************************************************************

<AttributeUsage(AttributeTargets.Field + AttributeTargets.Property + AttributeTargets.Class)> _
Public Class TransactionalAttribute

    Inherits System.Attribute

    Private m_bTransactional As Boolean = False

    Public Property Transactional() As Boolean
        Get
            Return m_bTransactional
        End Get
        Set(ByVal Value As Boolean)
            m_bTransactional = Value
        End Set
    End Property


    Public Sub New(ByVal Transact As Boolean)
        m_bTransactional = Transact
    End Sub

End Class

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions