14
14
Bus bus = Bus.Session;
16
ObjectPath myOpath = new ObjectPath ("/org/ndesk/test");
17
string myNameReq = "org.ndesk.test";
21
if (bus.NameHasOwner (myNameReq)) {
22
demo = bus.GetObject<IDemoObject> (myNameReq, myOpath);
24
demo = new DemoObject ();
25
bus.Register (myNameReq, myOpath, demo);
27
RequestNameReply nameReply = bus.RequestName (myNameReq);
28
Console.WriteLine ("RequestNameReply: " + nameReply);
16
string bus_name = "org.ndesk.test";
17
ObjectPath path = new ObjectPath ("/org/ndesk/test");
21
if (bus.RequestName (bus_name) == RequestNameReply.PrimaryOwner) {
22
//create a new instance of the object to be exported
24
bus.Register (path, demo);
30
//import a remote to a local proxy
31
demo = bus.GetObject<IDemo> (bus_name, path);
34
34
Console.WriteLine ();
35
demo.SomeEvent += HandleSomeEventA;
36
demo.FireOffSomeEvent ();
39
demo.SomeEvent -= HandleSomeEventA;
40
demo.FireOffSomeEvent ();
35
43
demo.SomeEvent += delegate (string arg1, object arg2, double arg3, MyTuple mt) {Console.WriteLine ("SomeEvent handler: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B);};
36
44
demo.SomeEvent += delegate (string arg1, object arg2, double arg3, MyTuple mt) {Console.WriteLine ("SomeEvent handler two: " + arg1 + ", " + arg2 + ", " + arg3 + ", " + mt.A + ", " + mt.B);};
37
45
demo.FireOffSomeEvent ();
38
//handle the raised signal
42
demo.SomeEvent += HandleSomeEventA;
43
demo.FireOffSomeEvent ();
44
//handle the raised signal
48
demo.SomeEvent -= HandleSomeEventA;
49
demo.FireOffSomeEvent ();
50
//handle the raised signal
49
Console.WriteLine (demo.GetSomeVariant ());
53
demo.Say2 ("demo.Say2");
54
((IDemoTwo)demo).Say2 ("((IDemoTwo)demo).Say2");
56
demo.SayEnum (DemoEnum.Bar, DemoEnum.Foo);
61
demo.WithOutParameters (out n, "21", out ostr);
62
Console.WriteLine ("n: " + n);
63
Console.WriteLine ("ostr: " + ostr);
67
IDemoOne[] objs = demo.GetObjArr ();
68
foreach (IDemoOne obj in objs)
72
demo.ThrowSomeException ();
56
75
public static void HandleSomeEventA (string arg1, object arg2, double arg3, MyTuple mt)
67
86
[Interface ("org.ndesk.test")]
68
public interface IDemoObject
87
public interface IDemoOne
70
89
event SomeEventHandler SomeEvent;
71
90
void FireOffSomeEvent ();
72
91
void Say (object var);
92
void SayEnum (DemoEnum a, DemoEnum b);
93
void Say2 (string str);
94
object GetSomeVariant ();
95
void ThrowSomeException ();
96
void WithOutParameters (out uint n, string str, out string ostr);
97
IDemoOne[] GetEmptyObjArr ();
98
IDemoOne[] GetObjArr ();
75
101
[Interface ("org.ndesk.test2")]
76
public interface IDemoObjectTwo
102
public interface IDemoTwo
78
104
int Say (string str);
81
public class DemoObject : IDemoObject, IDemoObjectTwo
105
void Say2 (string str);
108
public interface IDemo : IDemoOne, IDemoTwo
112
public class Demo : DemoBase
114
public override void Say2 (string str)
116
Console.WriteLine ("Subclassed IDemoOne.Say2: " + str);
120
public class DemoBase : IDemo
83
122
public event SomeEventHandler SomeEvent;
93
132
return str.Length;
135
public void SayEnum (DemoEnum a, DemoEnum b)
137
Console.WriteLine ("IDemoOne.Say2: " + a + ", " + b);
140
public virtual void Say2 (string str)
142
Console.WriteLine ("IDemoOne.Say2: " + str);
145
void IDemoTwo.Say2 (string str)
147
Console.WriteLine ("IDemoTwo.Say2: " + str);
96
150
public void FireOffSomeEvent ()
98
152
Console.WriteLine ("Asked to fire off SomeEvent");
106
160
Console.WriteLine ("Fired off SomeEvent");
164
public object GetSomeVariant ()
166
Console.WriteLine ("GetSomeVariant()");
171
public void ThrowSomeException ()
173
throw new Exception ("Some exception");
176
public void WithOutParameters (out uint n, string str, out string ostr)
178
n = UInt32.Parse (str);
179
ostr = "." + str + ".";
182
public IDemoOne[] GetEmptyObjArr ()
184
return new Demo[] {};
187
public IDemoOne[] GetObjArr ()
189
return new IDemoOne[] {this};
193
public enum DemoEnum : byte