72 lines
2.2 KiB
C#
72 lines
2.2 KiB
C#
#region
|
|
|
|
using System;
|
|
using System.IO;
|
|
using Autodesk.RevitAddIns;
|
|
|
|
#endregion
|
|
|
|
namespace DimensionTools.AddInDeployer
|
|
{
|
|
public class AddInManager
|
|
{
|
|
private readonly string vendorDescription = "深圳市地铁集团有限公司";
|
|
private readonly string vendorid = "SZMC";
|
|
|
|
internal AddInManager(string revitVersion, string addinname)
|
|
{
|
|
Manifest = new RevitAddInManifest();
|
|
ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
|
|
"Autodesk\\ApplicationPlugins\\DimensionTools.bundle\\Contents", revitVersion, addinname);
|
|
//ManifestPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "Autodesk\\Revit\\Addins", revitVersion, addinname);
|
|
}
|
|
|
|
private RevitAddInManifest Manifest { get; }
|
|
|
|
private string ManifestPath { get; }
|
|
|
|
|
|
internal void CreateApplication(string name, string assemblyPath, string fullClassName)
|
|
{
|
|
RevitAddInApplication item =
|
|
new RevitAddInApplication(name, assemblyPath, Guid.NewGuid(), fullClassName, vendorid)
|
|
{
|
|
VendorDescription = vendorDescription
|
|
};
|
|
Manifest.AddInApplications.Add(item);
|
|
}
|
|
|
|
internal void CreateCommand(string assemblyPath, string fullClassName)
|
|
{
|
|
RevitAddInCommand item = new RevitAddInCommand(assemblyPath, Guid.NewGuid(), fullClassName, vendorid)
|
|
{
|
|
VendorDescription = 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);
|
|
}
|
|
}
|
|
}
|
|
} |