Skip to content

Commit

Permalink
Update startup and shutdown methods to virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
ricaun committed Jan 20, 2025
1 parent f03be37 commit fe46980
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 15 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Features
- Initial release.
### DesignApplication
- Add `DesignApplication<T>` option.
- Update `DesignApplication` startup and shutdown methods to virtual.
- Add `DesignApplicationLoader` to fix [Design Automation for Revit ignores PackageContents.xml configuration.](https://github.com/ricaun-io/RevitAddin.DA.Tester/issues/7)
- Add `ExternalServer` to fix [Design Automation for Revit ActiveAddInId is null](https://github.com/ricaun-io/RevitAddin.DA.Tester/issues/9)
### Application
- Sample to execute `ricaun.Revit.DA` library.
- Add `DesignAutomation` class with interface `IDesignAutomation`.
### Tests
- Test `ricaun.Revit.DA` library.
- Update `TestCase` with expected results. (`Reference`, `TargetFramework` and `ActiveAddInId`)
Expand Down
19 changes: 7 additions & 12 deletions ricaun.Revit.DA.Example/Revit/App.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,18 @@

namespace ricaun.Revit.DA.Example.Revit
{
public class App : DesignApplication
public class App : DesignApplication<DesignAutomation>
{
public override bool Execute(Application application, string filePath, Document document)

}

public class DesignAutomation : IDesignAutomation
{
public bool Execute(Application application, string filePath, Document document)
{
var output = RevitOutputModel.Create(application);
output.Save();
return true;
}

public override void OnStartup()
{

}

public override void OnShutdown()
{

}
}
}
2 changes: 1 addition & 1 deletion ricaun.Revit.DA.Tests/Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public class Tests : BundleFileTests
{
//[TestCase("2024", "4.7", "19", null)]
//[TestCase("2025", "4.7", "19", null)]
//[TestCase("2019", "4.7", "19", "Example")]
[TestCase("2019", "4.7", "19", "Example")]
//[TestCase("2020", "4.7", "19", "Example")]
[TestCase("2024", "4.8", "21", "Example")]
[TestCase("2025", "8.0", "25", "Example")]
Expand Down
12 changes: 10 additions & 2 deletions ricaun.Revit.DA/DesignApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@

namespace ricaun.Revit.DA
{
public abstract class DesignApplication<T> : DesignApplication where T : IDesignAutomation
{
public override bool Execute(Application application, string filePath, Document document)
{
return Activator.CreateInstance<T>().Execute(application, filePath, document);
}
}

public abstract class DesignApplication : IExternalDBApplication, IDesignAutomation
{
/// <summary>
Expand All @@ -18,8 +26,8 @@ public abstract class DesignApplication : IExternalDBApplication, IDesignAutomat
/// </summary>
public virtual bool UseDesignApplicationLoader => true;
public ControlledApplication ControlledApplication { get; private set; }
public abstract void OnStartup();
public abstract void OnShutdown();
public virtual void OnStartup() { }
public virtual void OnShutdown() { }
public abstract bool Execute(Application application, string filePath, Document document);

private IExternalDBApplication designApplication;
Expand Down

0 comments on commit fe46980

Please sign in to comment.