?
Solved

Convert from C# to VB.net

Posted on 2013-01-18
4
Medium Priority
?
388 Views
Last Modified: 2013-01-18
Hello.  I ran this code through a converter but it failed :(

I don't understand the purpose of the square brackets in C#

Could someone convert it for me please?

[Table]
public class ToDoItem : INotifyPropertyChanged, INotifyPropertyChanging
{
// Define ID: private field, public property and database column.
private int _toDoItemId;

[Column(IsPrimaryKey = true, IsDbGenerated = true, DbType = "INT NOT NULL Identity", CanBeNull = false, AutoSync = AutoSync.OnInsert)]
public int ToDoItemId
{
    get
    {
        return _toDoItemId;
    }
    set
    {
        if (_toDoItemId != value)
        {
            NotifyPropertyChanging("ToDoItemId");
            _toDoItemId = value;
            NotifyPropertyChanged("ToDoItemId");
        }
    }
}

// Define item name: private field, public property and database column.
private string _itemName;

[Column]
public string ItemName
{
    get
    {
        return _itemName;
    }
    set
    {
        if (_itemName != value)
        {
            NotifyPropertyChanging("ItemName");
            _itemName = value;
            NotifyPropertyChanged("ItemName");
        }
    }
}

// Define completion value: private field, public property and database column.
private bool _isComplete;

[Column]
public bool IsComplete
{
    get
    {
        return _isComplete;
    }
    set
    {
        if (_isComplete != value)
        {
            NotifyPropertyChanging("IsComplete");
            _isComplete = value;
            NotifyPropertyChanged("IsComplete");
        }
    }
}
// Version column aids update performance.
[Column(IsVersion = true)]
private Binary _version;

#region INotifyPropertyChanged Members

public event PropertyChangedEventHandler PropertyChanged;

// Used to notify the page that a data context property changed
private void NotifyPropertyChanged(string propertyName)
{
    if (PropertyChanged != null)
    {
        PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
    }
}

#endregion

#region INotifyPropertyChanging Members

public event PropertyChangingEventHandler PropertyChanging;

// Used to notify the data context that a data context property is about to change
private void NotifyPropertyChanging(string propertyName)
{
    if (PropertyChanging != null)
    {
        PropertyChanging(this, new PropertyChangingEventArgs(propertyName));
    }
}

#endregion
}

Open in new window

0
Comment
Question by:Dodsworth
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38792963
Square brackets (as used above) denote attributes. In VB.NET, you use angle brackets ( < > ) for attributes.

Does this work? If not, what line(s) are in error?

<Table> _
Public Class ToDoItem
    Implements INotifyPropertyChanged
    Implements INotifyPropertyChanging
    ' Define ID: private field, public property and database column.
    Private _toDoItemId As Integer

    <Column(IsPrimaryKey := True, IsDbGenerated := True, DbType := "INT NOT NULL Identity", CanBeNull := False, AutoSync := AutoSync.OnInsert)> _
    Public Property ToDoItemId() As Integer
        Get
            Return _toDoItemId
        End Get
        Set
            If _toDoItemId <> value Then
                NotifyPropertyChanging("ToDoItemId")
                _toDoItemId = value
                NotifyPropertyChanged("ToDoItemId")
            End If
        End Set
    End Property

    ' Define item name: private field, public property and database column.
    Private _itemName As String

    <Column> _
    Public Property ItemName() As String
        Get
            Return _itemName
        End Get
        Set
            If _itemName <> value Then
                NotifyPropertyChanging("ItemName")
                _itemName = value
                NotifyPropertyChanged("ItemName")
            End If
        End Set
    End Property

    ' Define completion value: private field, public property and database column.
    Private _isComplete As Boolean

    <Column> _
    Public Property IsComplete() As Boolean
        Get
            Return _isComplete
        End Get
        Set
            If _isComplete <> value Then
                NotifyPropertyChanging("IsComplete")
                _isComplete = value
                NotifyPropertyChanged("IsComplete")
            End If
        End Set
    End Property
    ' Version column aids update performance.
    <Column(IsVersion := True)> _
    Private _version As Binary

    #Region "INotifyPropertyChanged Members"

    Public Event PropertyChanged As PropertyChangedEventHandler

    ' Used to notify the page that a data context property changed
    Private Sub NotifyPropertyChanged(propertyName As String)
        RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(propertyName))
    End Sub

    #End Region

    #Region "INotifyPropertyChanging Members"

    Public Event PropertyChanging As PropertyChangingEventHandler

    ' Used to notify the data context that a data context property is about to change
    Private Sub NotifyPropertyChanging(propertyName As String)
        RaiseEvent PropertyChanging(Me, New PropertyChangingEventArgs(propertyName))
    End Sub

    #End Region
End Class

'=======================================================
'Service provided by Telerik (www.telerik.com)
'Conversion powered by NRefactory.
'Twitter: @telerik, @toddanglin
'Facebook: facebook.com/telerik
'=======================================================

Open in new window

0
 
LVL 1

Author Comment

by:Dodsworth
ID: 38793003
that's solved the square bracket problem


errors on

Implements INotifyPropertyChanged
Implements INotifyPropertyChanging

Error      1      Class 'ToDoItem' must implement 'Event PropertyChanged(sender As Object, e As PropertyChangedEventArgs)' for interface 'System.ComponentModel.INotifyPropertyChanged'.      C:\Users\maf\documents\visual studio 2010\Projects\BTDT\BTDT\MainPage.xaml.vb      55      20      BTDT
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38793055
Change line 61 in my last snippet to:

Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged

Open in new window


...and line 72 to:

Public Event PropertyChanging As PropertyChangingEventHandler Implements INotifyPropertyChanging.PropertyChanging

Open in new window

0
 
LVL 1

Author Closing Comment

by:Dodsworth
ID: 38793376
thanks
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question