-
Notifications
You must be signed in to change notification settings - Fork 307
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c0fb599
commit 9564ad1
Showing
4 changed files
with
73 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Xml.Linq; | ||
|
||
namespace DependenciesReport; | ||
|
||
public static class AddinUtilities | ||
{ | ||
public static IGrouping<string, string>[] GetAddinLocations() | ||
{ | ||
var userFolder = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); | ||
var machineFolder = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); | ||
|
||
var userAddinsPath = Path.Combine(userFolder, "Autodesk", "Revit", "Addins"); | ||
var machineAddinsPath = Path.Combine(machineFolder, "Autodesk", "Revit", "Addins"); | ||
var storeAddinsPath = Path.Combine(machineFolder, "Autodesk", "ApplicationPlugins"); | ||
|
||
return Directory.EnumerateFiles(userAddinsPath, "*.addin", SearchOption.AllDirectories) | ||
.Union(Directory.EnumerateFiles(machineAddinsPath, "*.addin", SearchOption.AllDirectories)) | ||
.Union(Directory.EnumerateFiles(storeAddinsPath, "*.addin", SearchOption.AllDirectories)) | ||
.GroupBy(file => Path.GetFileName(Path.GetDirectoryName(file))!) | ||
.ToArray(); | ||
} | ||
|
||
public static Dictionary<string, string> GetAddinDirectories(IGrouping<string, string> addinLocation) | ||
{ | ||
var addinDirectories = new Dictionary<string, string>(); | ||
|
||
foreach (var manifest in addinLocation) | ||
{ | ||
try | ||
{ | ||
var document = XDocument.Load(manifest); | ||
|
||
var addInElement = document.Descendants("AddIn").FirstOrDefault(); | ||
if (addInElement == null) continue; | ||
|
||
var nameElement = addInElement.Element("Name"); | ||
var name = nameElement != null ? nameElement.Value : Path.GetFileNameWithoutExtension(manifest); | ||
|
||
var assemblyElement = addInElement.Element("Assembly"); | ||
if (assemblyElement == null) continue; | ||
|
||
var assemblyPath = assemblyElement.Value; | ||
if (!Path.IsPathRooted(assemblyPath)) | ||
{ | ||
var directoryName = Path.GetDirectoryName(manifest)!; | ||
assemblyPath = Path.Combine(directoryName, assemblyPath); | ||
} | ||
|
||
if (File.Exists(assemblyPath)) | ||
{ | ||
addinDirectories[name] = Path.GetDirectoryName(assemblyPath)!; | ||
} | ||
} | ||
catch | ||
{ | ||
Console.WriteLine($"Bad file: {manifest}"); | ||
} | ||
} | ||
|
||
return addinDirectories; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=addin/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=addins/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters