forked from Excel-DNA/Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddIn.cs
More file actions
40 lines (36 loc) · 1.16 KB
/
Copy pathAddIn.cs
File metadata and controls
40 lines (36 loc) · 1.16 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
34
35
36
37
38
39
40
using System.Collections.Generic;
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using ExcelDna.Integration;
using ExcelDna.Logging;
namespace AddInReloader
{
public class AddIn : IExcelAddIn
{
AddInWatcher _watcher;
public void AutoOpen()
{
var configFileName = "AddInReloaderConfiguration.xml";
var xllDirectory = Path.GetDirectoryName(ExcelDnaUtil.XllPath);
var configPath = Path.Combine(xllDirectory, configFileName);
try
{
// Load config
XmlSerializer configLoader = new XmlSerializer(typeof(AddInReloaderConfiguration));
AddInReloaderConfiguration config = (AddInReloaderConfiguration)configLoader.Deserialize(File.OpenRead(configPath));
_watcher = new AddInWatcher(config);
}
catch (Exception ex)
{
LogDisplay.WriteLine("AddInReloader - Error loading the configuration file: " + ex.ToString());
}
}
public void AutoClose()
{
_watcher.Dispose();
}
}
}