File: TestSample.cs

package info (click to toggle)
dbus-sharp 0.8.1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 868 kB
  • sloc: cs: 7,690; sh: 494; makefile: 181
file content (54 lines) | stat: -rw-r--r-- 1,420 bytes parent folder | download | duplicates (4)
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
// Copyright 2006 Alp Toker <alp@atoker.com>
// This software is made available under the MIT License
// See COPYING for details

using System;
using System.Collections.Generic;
using DBus;
using org.freedesktop.DBus;

public class ManagedDBusTestSample
{
	public static void Main ()
	{
		Bus bus = Bus.Session;

		SampleInterface sample = bus.GetObject<SampleInterface> ("com.example.SampleService", new ObjectPath ("/SomeObject"));

		Console.WriteLine ();
		string xmlData = sample.Introspect ();
		Console.WriteLine ("xmlData: " + xmlData);

		//object obj = sample.HelloWorld ("Hello from example-client.py!");
		string[] vals = sample.HelloWorld ("Hello from example-client.py!");
		foreach (string val in vals)
			Console.WriteLine (val);

		Console.WriteLine ();
		MyTuple tup = sample.GetTuple ();
		Console.WriteLine (tup.A);
		Console.WriteLine (tup.B);

		Console.WriteLine ();
		IDictionary<string,string> dict = sample.GetDict ();
		foreach (KeyValuePair<string,string> pair in dict)
			Console.WriteLine (pair.Key + ": " + pair.Value);
	}
}

[Interface ("com.example.SampleInterface")]
public interface SampleInterface : Introspectable
{
	//void HelloWorld (object hello_message);
	//object HelloWorld (object hello_message);
	string[] HelloWorld (object hello_message);
	MyTuple GetTuple ();
	IDictionary<string,string> GetDict ();
}

//(ss)
public struct MyTuple
{
	public string A;
	public string B;
}