jeremytammik / RevitLookup

Interactive Revit RFA and RVT project database exploration tool to view and navigate BIM element parameters, properties and relationships.
http://thebuildingcoder.typepad.com
MIT License
1.03k stars 294 forks source link

Ignore `ActionEventHandler` when null - UI.Demo #199

Closed ricaun closed 6 months ago

ricaun commented 6 months ago

Summary of the Pull Request

When using UI.Demo the Application.ActionEventHandler is null.

The EventMonitor.Subscribe and EventMonitor.Unsubscribe throw exception.

Quality Checklist

ricaun commented 6 months ago

A better solution would be to create a Mock viewmodel to create logic for the demo project that does not reference the Revit Api

Yes. I'm not sure if this is right, the IEventsViewModel is something like this.

public interface IEventsViewModel : ISnoopViewModel
{
    void OnNavigatedTo();
    void OnNavigatedFrom();
}
ricaun commented 6 months ago

A better solution would be to create a Mock viewmodel to create logic for the demo project that does not reference the Revit Api

Yes. I'm not sure if this is right, the IEventsViewModel is something like this.

public interface IEventsViewModel : ISnoopViewModel
{
    void OnNavigatedTo();
    void OnNavigatedFrom();
}

Or this. 😀

public interface IEventsViewModel : INavigationAware, ISnoopViewModel 
{
}
Nice3point commented 6 months ago

Or this. 😀

public interface IEventsViewModel : INavigationAware, ISnoopViewModel 
{
}

or this 😉

public interface IEventsViewModel : INavigationAware, ISnoopViewModel;

in C# 12 you can use ; instead of {} yeah, that's a great plan, let's do that)

ricaun commented 6 months ago
IEventsViewModel 

Done! I added a Subscribe/Unsubscribe in the moq. Strange that all de RevitApi.dll is loaded when you go into the Events.

Nice3point commented 6 months ago

Awesome, thanks)

Nice3point commented 6 months ago

Strange that all de RevitApi.dll is loaded when you go into the Events.

There because of using using Autodesk.Revit.Exceptions; in SnoopViewModelBase, I fixed it by inheriting ObservableObject instead of SnoopViewModelBase