My .NET Core talks - demo5
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
Program.cs
README.md
UPower.DBus.cs
demo5.csproj
demo5.sln

README.md

C# on Linux - demo5

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.

Resources:

Steps:

  1. For this demo we need dotnet sdk installed, and an IDE of your choice. You can find out more at fedoraloves.net
  2. Add NuGet repository for tmds.DBus
    1. Edit the NuGet configuration:
      $ vim ~/.nuget/NuGet/NuGet.Config
    2. Add a new packageSource:
      <add key="tmds" value="https://www.myget.org/F/tmds/api/v3/index.json" protocolVersion="3" />
  3. Create a new console application:
    $ mkdir demo5 && cd demo5
    $ dotnet new console
  4. Edit the project file to include tmds.DBus
    $ vim demo5.csproj
  5. Run $ dotnet restore to get the NuGet packages we need.
  6. 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
  7. 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
  8. Play with it =)