72 lines
1.7 KiB
C#
72 lines
1.7 KiB
C#
|
|
#region
|
|||
|
|
|
|||
|
|
using System;
|
|||
|
|
using System.IO;
|
|||
|
|
using Autodesk.RevitAddIns;
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
namespace Sai.AddInDeployer
|
|||
|
|
{
|
|||
|
|
public class AddInManager
|
|||
|
|
{
|
|||
|
|
private RevitAddInManifest Manifest { get; }
|
|||
|
|
|
|||
|
|
private string ManifestPath { get; }
|
|||
|
|
|
|||
|
|
internal AddInManager(string revitVersion, string addInName)
|
|||
|
|
{
|
|||
|
|
Manifest = new RevitAddInManifest();
|
|||
|
|
ManifestPath = Path.Combine(
|
|||
|
|
Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
|||
|
|
$@"Autodesk\ApplicationPlugins\{Contraints.BundleFolderName}\Contents",
|
|||
|
|
revitVersion,
|
|||
|
|
addInName
|
|||
|
|
);
|
|||
|
|
//ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Autodesk\\Revit\\Addins", revitVersion, addInName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal void CreateApplication(string name, string assemblyPath, string fullClassName)
|
|||
|
|
{
|
|||
|
|
RevitAddInApplication item = new RevitAddInApplication(name, assemblyPath, Guid.NewGuid(), fullClassName, Contraints.VendorId)
|
|||
|
|
{
|
|||
|
|
VendorDescription = Contraints.VendorDescription
|
|||
|
|
};
|
|||
|
|
Manifest.AddInApplications.Add(item);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal void CreateCommand(string assemblyPath, string fullClassName)
|
|||
|
|
{
|
|||
|
|
RevitAddInCommand item = new RevitAddInCommand(assemblyPath, Guid.NewGuid(), fullClassName, Contraints.VendorId)
|
|||
|
|
{
|
|||
|
|
VendorDescription = Contraints.VendorDescription
|
|||
|
|
};
|
|||
|
|
Manifest.AddInCommands.Add(item);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal void Install()
|
|||
|
|
{
|
|||
|
|
DirectoryInfo directory = new FileInfo(ManifestPath).Directory;
|
|||
|
|
if (directory == null)
|
|||
|
|
{
|
|||
|
|
return;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (!directory.Exists)
|
|||
|
|
{
|
|||
|
|
Directory.CreateDirectory(directory.FullName);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Manifest.SaveAs(ManifestPath);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal void Uninstall()
|
|||
|
|
{
|
|||
|
|
if (File.Exists(ManifestPath))
|
|||
|
|
{
|
|||
|
|
File.Delete(ManifestPath);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|