-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathWebApiTester.cs
84 lines (75 loc) · 10.3 KB
/
WebApiTester.cs
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.IO;
using System.Linq;
using System.Reflection;
using XrmToolBox.Extensibility;
using XrmToolBox.Extensibility.Interfaces;
namespace AshV.WebApiTester.XTB
{
// Do not forget to update version number and author (company attribute) in AssemblyInfo.cs class
// To generate Base64 string for Images below, you can use https://www.base64-image.de/
[Export(typeof(IXrmToolBoxPlugin)),
ExportMetadata("Name", "✈ WebAPI Launcher"),
ExportMetadata("Description", "Execute and Test Dataverse/Dynamics 365 WebAPIs."),
// Please specify the base64 content of a 32x32 pixels image
ExportMetadata("SmallImageBase64", "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAC+lBMVEUAAAD9/f3////+/v7KyspkCoRlDYhlDIdKAHRkDIdjDIZkDYdlDYeQMqTBoc9mD4piC4i4j8hxIJJkDIZlCoJlDYlkDIhlDohjCoZkDYhmDolkCoZlDIhmEYlkC4hlDYZeBo1nEIqlcrp/NpxkC4r8/Pz9/f3+/v78/Pz+/v7+/v74+Pj+/v7////+/v7+/v7////////19fX+/v7///////9lDYhlDYhlDYj+/v7////+/v5kDIVkDIZlDYhlDYhlDYhlDIhlDoj+/f7///////9lDYhlDYhlDYhlDYhlDYhlDYidZ7T8+v3///////9lDYhlDYhlDYhlDYjq3++VWa1aAIBmDYhlDYhlDYijb7hkDIdlDYhlDYhlDYdlDYhlDY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b2Do5OzlYurkxo8gJsbG7uHp5e3jt37fTx3e3nLygkjKKAhy0gMGjnzmCg/J69u0NCw8LZRNhRFIhGRO4Egl079+3ffSAqOiY2TpSdE+48MTE223io/MHduw8dPrJzZ0KiuIQkRJ5Nii0pOSUVLH90/+7dx46fAClOS2djA8tLs7FlZGZB9B89uXv3qdNnzp47d37nzuwcNnaQO9jYcvN2wu3fvfvCxUuXL1+5em1nfkGhqIwMAwN3UXEJWMH1o0D7d+++cfPWrdt37t7buTMoobQMqIKtvAIsf+b+g90PHz66DVL0+Mm9XSCxyio2oILqGrCCa0+fPX/+4uUroPzrJ9fB8jt31taxMbDVQ2zY+ebt23M7393Yvfv9kw9Q+Z0NjUAFTc07YeDEx9e7d3+C69+5s6QFqCC5Fcb9/OUrUP83uP6dO5vbgAraO2DcN99/7P75DaF/506HTjYGGbaqLqj8r9+o+nfu7O4BmiDT29YH5t37g6Z/Z/8ENllQWsmZOGnylKnTpv+dMXPW7KkwMGVO4Fw2djlQYEuyzZu/YOGixUuWLlu+Ag5WrlrNJs8Dji8xBR42RaU1a9f5K3OyIQExFR54imFi0lq/YSN6SkTKikybNq9Rw5PZmJm3bN2GWz/QBNXtO5jx5WZgXsclDwCcMk14faDVYAAAACV0RVh0ZGF0ZTpjcmVhdGUAMjAyMS0wMi0xMFQxNTowMjo1MiswMDowMLMMUpUAAAAldEVYdGRhdGU6bW9kaWZ5ADIwMjEtMDItMTBUMTU6MDI6NTIrMDA6MDDCUeopAAAAAElFTkSuQmCC"),
// Please specify the base64 content of a 80x80 pixels image
ExportMetadata("BigImageBase64", "iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAB3RJTUUH5QIKDwIdxUza8wAADHBJREFUeNrtnHt0VF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yMDIxLTAyLTEwVDE0OjU5OjUzKzAwOjAwMAdvrQAAAABJRU5ErkJggg=="),
ExportMetadata("BackgroundColor", "Purple"),
ExportMetadata("PrimaryFontColor", "White"),
ExportMetadata("SecondaryFontColor", "White")]
public class WebApiTester : PluginBase
{
public override IXrmToolBoxPluginControl GetControl()
{
return new WebApiTesterControl();
}
/// <summary>
/// Constructor
/// </summary>
public WebApiTester()
{
// If you have external assemblies that you need to load, uncomment the following to
// hook into the event that will fire when an Assembly fails to resolve
// AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(AssemblyResolveEventHandler);
}
/// <summary>
/// Event fired by CLR when an assembly reference fails to load
/// Assumes that related assemblies will be loaded from a subfolder named the same as the Plugin
/// For example, a folder named Sample.XrmToolBox.MyPlugin
/// </summary>
/// <param name="sender"></param>
/// <param name="args"></param>
/// <returns></returns>
private Assembly AssemblyResolveEventHandler(object sender, ResolveEventArgs args)
{
Assembly loadAssembly = null;
Assembly currAssembly = Assembly.GetExecutingAssembly();
// base name of the assembly that failed to resolve
var argName = args.Name.Substring(0, args.Name.IndexOf(","));
// check to see if the failing assembly is one that we reference.
List<AssemblyName> refAssemblies = currAssembly.GetReferencedAssemblies().ToList();
var refAssembly = refAssemblies.Where(a => a.Name == argName).FirstOrDefault();
// if the current unresolved assembly is referenced by our plugin, attempt to load
if (refAssembly != null)
{
// load from the path to this plugin assembly, not host executable
string dir = Path.GetDirectoryName(currAssembly.Location).ToLower();
string folder = Path.GetFileNameWithoutExtension(currAssembly.Location);
dir = Path.Combine(dir, folder);
var assmbPath = Path.Combine(dir, $"{argName}.dll");
if (File.Exists(assmbPath))
{
loadAssembly = Assembly.LoadFrom(assmbPath);
}
else
{
throw new FileNotFoundException($"Unable to locate dependency: {assmbPath}");
}
}
return loadAssembly;
}
}
}