This repository contains .NET Core demo that I use during some of my talks. Please note that this code contains hacks and should not be taken seriously - it serves only as demonstration of interacting with the Linux system.
This demo is built on top of Tom's DBus library.
- For this demo we need dotnet sdk installed, and an IDE of your choice. You can find out more at fedoraloves.net
- Add NuGet repository for tmds.DBus
- Edit the NuGet configuration:
$ vim ~/.nuget/NuGet/NuGet.Config
- Add a new packageSource:
<add key="tmds" value="https://www.myget.org/F/tmds/api/v3/index.json" protocolVersion="3" />
- Edit the NuGet configuration:
- Create a new console application:
$ mkdir demo5 && cd demo5
$ dotnet new console
- Edit the project file to include
tmds.DBus
$ vim demo5.csproj
- Run
$ dotnet restore
to get the NuGet packages we need. - List DBus services and find objects for org.freedesktop.UPower:
$ dotnet dbus list --bus system services | grep -i power
-org.freedesktop.UPower
$ dotnet dbus list --bus system --service org.freedesktop.UPower objects | head -1
-/org/freedesktop/UPower : org.freedesktop.UPower
- Generate C# interfaces for the UPower service:
$ dotnet dbus codegen --bus system --service org.freedesktop.UPower
-Generated: /home/rjanek/dev/dotnettalks/demo5/UPower.DBus.cs
- Play with it =)