-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
4 changed files
with
75 additions
and
0 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
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
48 changes: 48 additions & 0 deletions
48
samples/Modules.AssemblyResolution.Actions/AssemblyResolutionAction.cs
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,48 @@ | ||
// -------------------------------------------------------------- | ||
// Copyright (c) Jesus Fernandez. All Rights Reserved. | ||
// -------------------------------------------------------------- | ||
|
||
using System; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Reflection; | ||
using Azure.Core; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK; | ||
using Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK.Attributes; | ||
|
||
namespace PowerAutomate.Desktop.Modules.AssemblyResolution.Actions; | ||
|
||
[Action] | ||
public class AssemblyResolutionAction : ActionBase | ||
{ | ||
public override void Execute(ActionContext context) | ||
{ | ||
Debugger.Launch(); | ||
|
||
try | ||
{ | ||
AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve; | ||
|
||
var accessToken = new AccessToken(); | ||
Debug.WriteLine($"Access token expires on {accessToken.ExpiresOn}"); | ||
} | ||
finally | ||
{ | ||
AppDomain.CurrentDomain.AssemblyResolve -= CurrentDomain_AssemblyResolve; | ||
} | ||
} | ||
|
||
private static Assembly? CurrentDomain_AssemblyResolve(object sender, ResolveEventArgs args) | ||
{ | ||
try | ||
{ | ||
var assemblyName = new AssemblyName(args.Name); | ||
var directoryName = AppDomain.CurrentDomain.BaseDirectory; | ||
return !string.IsNullOrEmpty(directoryName) ? Assembly.LoadFile(Path.Combine(directoryName, $"{assemblyName.Name}.dll")) : null; | ||
} | ||
catch (Exception) | ||
{ | ||
return null; | ||
} | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
samples/Modules.AssemblyResolution.Actions/Modules.AssemblyResolution.Actions.csproj
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,16 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<AssemblyTitle>GettingStarted</AssemblyTitle> | ||
<TargetFramework>net472</TargetFramework> | ||
<LangVersion>latest</LangVersion> | ||
<Nullable>enable</Nullable> | ||
<PackCustomModule Condition=" '$(Configuration)' == 'Debug' ">true</PackCustomModule> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Azure.Core" /> | ||
<PackageReference Include="Microsoft.PowerPlatform.PowerAutomate.Desktop.Actions.SDK" /> | ||
</ItemGroup> | ||
|
||
</Project> |