{"id":16202196,"url":"https://github.com/francedot/desktopbridge.extension","last_synced_at":"2025-07-06T03:07:39.675Z","repository":{"id":93070394,"uuid":"91623830","full_name":"francedot/DesktopBridge.Extension","owner":"francedot","description":"Desktop Bridge Extension to call Win32 APIs from UWP","archived":false,"fork":false,"pushed_at":"2017-05-18T10:46:58.000Z","size":69,"stargazers_count":7,"open_issues_count":2,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-03T00:01:48.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francedot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-17T22:01:24.000Z","updated_at":"2024-05-03T23:53:19.000Z","dependencies_parsed_at":"2023-03-14T04:00:34.637Z","dependency_job_id":null,"html_url":"https://github.com/francedot/DesktopBridge.Extension","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/francedot/DesktopBridge.Extension","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francedot%2FDesktopBridge.Extension","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francedot%2FDesktopBridge.Extension/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francedot%2FDesktopBridge.Extension/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francedot%2FDesktopBridge.Extension/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francedot","download_url":"https://codeload.github.com/francedot/DesktopBridge.Extension/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francedot%2FDesktopBridge.Extension/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263841616,"owners_count":23518488,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T09:46:11.973Z","updated_at":"2025-07-06T03:07:39.624Z","avatar_url":"https://github.com/francedot.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"## Desktop Bridge Extension Library for the UWP\n\nThe DesktopBridge.Extension Library allows for Win32 APIs to be called from the UWP (x86, x64) abstracting the standard IPC (Inter Process Comunication) approach in favour of a more testable API Interface.\n\nNuget package is in the works. If you want to try it out before its release just clone the repo.\n\n### Setup\n\n* Reference **DesktopBridge.Extension.Interface** and **Reference DesktopBridge.Extension.Shared** from the UWP project.\n* Modify the project **Package.appxmanifest**:\n\n  1. Add rescap and desktop namespaces: \n  ```xmlns:rescap=\"http://schemas.microsoft.com/appx/manifest/foundation/windows10/restrictedcapabilities\"```\n  ```xmlns:desktop=\"http://schemas.microsoft.com/appx/manifest/desktop/windows10\"```\n  2. Add ignorable namespaces: ```IgnorableNamespaces=\"uap mp rescap desktop\"```\n  3. Add the AppService Extension called DesktopBridgeMiddleware and register the embedded executable for running as a full trust process\n```xml\n\u003cExtensions\u003e\n  \u003cuap:Extension Category=\"windows.appService\"\u003e\n    \u003cuap:AppService Name=\"DesktopBridgeMiddleware\" /\u003e\n  \u003c/uap:Extension\u003e\n  \u003cdesktop:Extension Category=\"windows.fullTrustProcess\" Executable=\"desktop\\DesktopBridge.Extension.Proxy.App.exe\" /\u003e\n\u003c/Extensions\u003e \n```\n\nSee the [DesktopBridge.Extension.SampleApp](https://github.com/francedot/DesktopBridge.Extension/tree/master/DesktopBridge.Extension/DesktopBridge.Extension.SampleApp) for further reference.\n\n### API Usage\n\n1. Make the App class inherit the **AppConnectionAware** abstract class in order for the APIs to gain access to the DesktopBridgeMiddleware AppService.\n2. In the App **OnLaunched**, call the base class implementation ```base.OnLaunched(e)```. This is responsible for initializing the AppService and launching the registered full trust process.\n\nAlternatively, make sure to obtain an instance of the DesktopBridgeMiddleware AppService by overriding the App **OnBackgroundActivated** and pass the **AppServiceConnection** to the **InflateConnection()** method of the **DesktopBridgeExtension** class. Lastly, call **InitializeAsync()** to start the full trust process.\n\n```csharp\n/// \u003csummary\u003e\n/// Starts the embedded full trust process\n/// \u003c/summary\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic async Task InitializeAsync();\n\n/// \u003csummary\u003e\n/// Inflates the DesktopBridgeMiddleware App Service Connection\n/// \u003c/summary\u003e\n/// \u003cparam name=\"appServiceConnection\"\u003eThe DesktopBridgeMiddleware App Service Connection\u003c/param\u003e\npublic void InflateConnection(AppServiceConnection appServiceConnection);\n```\n\nThe **DesktopBridgeExtension** exposes its implementation through its singleton: ```DesktopBridgeExtension.Instance```\n\n### Executing Main Programs\n\n```csharp\n\n/// \u003csummary\u003e\n/// Executes the Main Program\n/// \u003c/summary\u003e\n/// \u003cparam name=\"code\"\u003eThe code of the Main Program\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic async Task ExecuteMainProgramAsync(string code);\n\n/// \u003csummary\u003e\n/// Executes the Main Program\n/// \u003c/summary\u003e\n/// \u003cparam name=\"path\"\u003eThe path to a file containing the Main Program relative to the installed location\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic async Task ExecuteMainProgramFromFileAsync(string path);\n\n```\n#### Example: Execute a Console Main Program\n\n```csharp\n\nvar code =\n@\"using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Threading.Tasks;\n\nnamespace ConsoleApp\n{\n    class Program\n    {\n        static void Main(string[] args)\n        {\n            Console.WriteLine(\"\"Hello Desktop Bridge!\"\");\n            Console.ReadLine();\n        }\n    }\n}\";\n\nawait DesktopBridgeExtension.Instance.ExecuteMainProgramAsync(code);\n\n```\n\n### Executing Code Scripts\n\n```csharp\n/// \u003csummary\u003e\n/// Executes the Code Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"code\"\u003eThe code of the Script\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic async Task ExecuteScriptAsync(string code);\n\n/// \u003csummary\u003e\n/// Executes the Code Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"path\"\u003eThe path to a file containing the code of the Script relative to the installed location\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic async Task ExecuteScriptFromFileAsync(string path);\n\n/// \u003csummary\u003e\n/// Executes the Code Script and returns a result value\n/// \u003c/summary\u003e\n/// \u003ctypeparam name=\"TResult\"\u003eThe Type of the expected Result\u003c/typeparam\u003e\n/// \u003cparam name=\"code\"\u003eThe code of the Script\u003c/param\u003e\n/// \u003creturns\u003eThe evaluated result\u003c/returns\u003e\npublic async Task\u003cTResult\u003e ExecuteScriptAsync\u003cTResult\u003e(string code);\n\n/// \u003csummary\u003e\n/// Executes the Code Script and returns a result value\n/// \u003c/summary\u003e\n/// \u003ctypeparam name=\"TResult\"\u003eThe Type of the expected Result\u003c/typeparam\u003e\n/// \u003cparam name=\"path\"\u003eThe path to a file containing the code of the Script relative to the installed location\u003c/param\u003e\n/// \u003creturns\u003eThe evaluated result\u003c/returns\u003e\npublic async Task\u003cTResult\u003e ExecuteScriptFromFileAsync\u003cTResult\u003e(string path);\n```\n\nAdditional informations can be passed with the Script by using the following set of Fluent APIs.\n\n#### Passing Parameters to a Script\n\n```csharp\n\n/// \u003csummary\u003e\n/// Adds a Parameter to be passed as a part of the Script\n/// \u003c/summary\u003e\n/// \u003ctypeparam name=\"TParam\"\u003eThe Type of the Parameter\u003c/typeparam\u003e\n/// \u003cparam name=\"paramName\"\u003eName of the Parameter\u003c/param\u003e\n/// \u003cparam name=\"paramValue\"\u003eValue of the Parameter\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic DesktopBridgeExtension WithParameter\u003cTParam\u003e(string paramName, TParam paramValue);\n\n```\n\n#### Passing Using directives to a Script\n\n```csharp\n\n/// \u003csummary\u003e\n/// Adds a Using directive to be passed as a part of the Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"using\"\u003eThe using namespace (without the using keyword)\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic DesktopBridgeExtension WithUsing(string @using);\n\n/// \u003csummary\u003e\n/// Adds a collection of Using directives to be passed as a part of the Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"usings\"\u003eA collection of using namespaces (without the using keyword)\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic DesktopBridgeExtension WithUsing(IEnumerable\u003cstring\u003e usings);\n\n```\n\n#### Passing Assembly References to a Script\n\n```csharp\n\n/// \u003csummary\u003e\n/// Adds an assembly path to be referenced by the Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"referencePath\"\u003ePath to the assembly relative to the project folder\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic DesktopBridgeExtension WithReference(string referencePath);\n\n/// \u003csummary\u003e\n/// Adds a collection of assembly paths to be referenced by the Script\n/// \u003c/summary\u003e\n/// \u003cparam name=\"referencePaths\"\u003ePaths to the assemblies relative to the installed location\u003c/param\u003e\n/// \u003creturns\u003e\u003c/returns\u003e\npublic DesktopBridgeExtension WithReference(IEnumerable\u003cstring\u003e referencePaths);\n\n```\n\n#### Example 1: Start a new Process passing its executable path\n\n```csharp\n\nvar code =\n@\"Process cmd = new Process\n  {\n    StartInfo = { FileName = path }\n  };\n  cmd.Start();\";\n\nawait DesktopBridgeExtension.Instance.WithParameter\u003cstring\u003e(\"path\", \"myExe.exe\").\n                                      ExecuteScriptAsync(code);\n\n```\n\n#### Example 2: Show a Notify Icon in the Taskbar\n\n```csharp\n\nvar code =\n@\"var notifyIcon = new NotifyIcon\n  {\n    BalloonTipText = @\"\"Hello, NotifyIcon!\"\",\n    Text = @\"\"Hello, NotifyIcon!\"\",\n    Icon = new Icon(\"\"NotifyIcon.ico\"\"),\n    Visible = true\n  };\n  notifyIcon.ShowBalloonTip(1000);\";\n\nawait DesktopBridgeExtension.Instance.WithUsing(\"System.Drawing\").\n                                      WithUsing(\"System.Windows\").\n                                      WithUsing(\"System.Windows.Forms\").\n                                      WithUsing(\"System.Diagnostics\").\n                                      WithUsing(\"System.Runtime.InteropServices\").\n                                      ExecuteScriptAsync(code);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancedot%2Fdesktopbridge.extension","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancedot%2Fdesktopbridge.extension","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancedot%2Fdesktopbridge.extension/lists"}