-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddInPathSettings.cs
More file actions
33 lines (26 loc) · 1.08 KB
/
Copy pathAddInPathSettings.cs
File metadata and controls
33 lines (26 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
using Autodesk.RevitAddIns;
using System.IO;
using System.Xml.Linq;
namespace AddinManagerWpf
{
public static class AddInFileManager
{
public static void UpdateAssemblyPath(RevitAddInManifest addIn, string fullClassName, string newAssemblyPath)
{
string addInPath = addIn.FullName;
if (!File.Exists(addInPath))
throw new FileNotFoundException("AddIn file not found", addInPath);
XDocument doc = XDocument.Load(addInPath);
XElement? addInElement = doc.Root?
.Elements("AddIn")
.FirstOrDefault(e => string.Equals(
e.Element("FullClassName")?.Value,
fullClassName,
StringComparison.OrdinalIgnoreCase));
if (addInElement == null)
throw new InvalidOperationException($"AddIn with FullClassName '{fullClassName}' not found in {addInPath}.");
addInElement.Element("Assembly")?.Value = newAssemblyPath;
doc.Save(addInPath);
}
}
}