添加项目文件。
This commit is contained in:
70
Sai.RvKits Setup/AddInManager.cs
Normal file
70
Sai.RvKits Setup/AddInManager.cs
Normal file
@@ -0,0 +1,70 @@
|
||||
#region
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
using Autodesk.RevitAddIns;
|
||||
|
||||
#endregion
|
||||
|
||||
namespace Sai.RvKits_Setup
|
||||
{
|
||||
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\{Settings.AddInAppName}.bundle\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)
|
||||
{
|
||||
var item =
|
||||
new RevitAddInApplication(name, assemblyPath, Guid.NewGuid(), fullClassName, Settings.VendorId)
|
||||
{
|
||||
VendorDescription = Settings.VendorDescription
|
||||
};
|
||||
Manifest.AddInApplications.Add(item);
|
||||
}
|
||||
|
||||
internal void CreateCommand(string assemblyPath, string fullClassName)
|
||||
{
|
||||
var item = new RevitAddInCommand(assemblyPath, Guid.NewGuid(), fullClassName, Settings.VendorId)
|
||||
{
|
||||
VendorDescription = Settings.VendorDescription
|
||||
};
|
||||
Manifest.AddInCommands.Add(item);
|
||||
}
|
||||
|
||||
internal void Install()
|
||||
{
|
||||
var 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