Quantcast
Channel: CSLA .NET
Viewing all articles
Browse latest Browse all 764

CSLA/Silverlight VB.Net "Presenter" code

$
0
0

Hi gents,

This is more a .Net C/VB question, but I'm trying to create a Silverlight project using VB.Net as opposed to the C# that is provided in examples..

Can anyone give me a pointer as to how THIS code is implemented as VB.Net?

       var presenter = (IPresenter)Bxf.Shell.Instance;
      presenter.OnShowError += (message, title) =>
        {
          Shell.Instance.ShowView(
            typeof(Views.ErrorDisplay).AssemblyQualifiedName,
            "errorViewSource",
            new ViewModels.Error { ErrorContent = message },
            "Error");
        };

      presenter.OnShowStatus += (status) =>
        {
          Shell.Instance.ShowView(
            typeof(Views.StatusDisplay).AssemblyQualifiedName,
            "statusViewSource",
            status,
            "Status");
        };

      presenter.OnShowView += (view, region) =>
        {
          switch (region)
          {
            case "Main":
              MainContent = view.ViewInstance;
              break;
            case "Menu":
              MenuContent = view.ViewInstance;
              break;
            case "User":
              UserContent = view.ViewInstance;
              break;
            case "Error":
              _errorClose = DateTime.Now.Add(new TimeSpan(0, 0, 5));
              ErrorContent = view.ViewInstance;
              break;
            case "Status":
              _statusClose = DateTime.Now.Add(new TimeSpan(0, 0, 5));
              if (view.Model != null)
                AppBusy = ((Bxf.Status)view.Model).IsBusy;
              else
                AppBusy = false;
              StatusContent = view.ViewInstance;
              break;
            default:
              break;
          }
        };

I've tried various conversion tools and the code they come up with is not valid.

I'm a VB guy and trying not to confuse matters even more by developing in a "foreign" language on top of having to learn Silverlight development, MVVM and upgrade to the latest CSLA...

Any help would be appreciated.

Thanks,

Graham

 edit: (as for whatever reason, it doesn't show my replies to my own post.. ugh).

Here's what have done for the OnShowView event in VB.Net, will this suffice?

    Public WithEvents presenter As IPresenter = DirectCast(Bxf.Shell.Instance, IPresenter)
    Private Sub presenter_OnShowView(ByVal view As Bxf.IView, ByVal region As String) Handles presenter.OnShowView

        Select Case region
            Case "Main"
                MainContent = view.ViewInstance
                Exit Select
            Case "Menu"
                MenuContent = view.ViewInstance
                Exit Select
            Case "User"
                UserContent = view.ViewInstance
                Exit Select
            Case "Error"
                _errorClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))
                ErrorContent = view.ViewInstance
                Exit Select
            Case "Status"
                _statusClose = DateTime.Now.Add(New TimeSpan(0, 0, 5))
                If view.Model IsNot Nothing Then
                    AppBusy = DirectCast(view.Model, Bxf.Status).IsBusy
                Else
                    AppBusy = False
                End If
                StatusContent = view.ViewInstance
                Exit Select
            Case Else
                Exit Select
        End Select

    End Sub


Viewing all articles
Browse latest Browse all 764

Trending Articles