添加项目文件。
This commit is contained in:
72
DimensionTools.AddInDeployer/AddInManager.cs
Normal file
72
DimensionTools.AddInDeployer/AddInManager.cs
Normal file
@@ -0,0 +1,72 @@
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user