本文整理汇总了C#中Client.Browse方法的典型用法代码示例。如果您正苦于以下问题:C# Client.Browse方法的具体用法?C# Client.Browse怎么用?C# Client.Browse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Client
的用法示例。
在下文中一共展示了Client.Browse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DescriptionCacheTest
public void DescriptionCacheTest()
{
var factory = new DummyDeserializerFactory ();
using (var server = new Server (CreateRoot ())) {
using (var client = new Client (factory.CreateDeserializer)) {
client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)));
client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (2, 0)));
flag = false;
client.ServiceAdded += (sender, args) => {
lock (mutex) {
var service = args.Service.GetService ();
Assert.IsNotNull (service);
if (flag) {
Monitor.Pulse (mutex);
} else {
flag = true;
}
}
};
lock (mutex) {
server.Start ();
if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
Assert.Fail ("The server announcement timed out.");
}
Assert.AreEqual (1, factory.InstantiationCount);
}
}
}
}
示例2: EventTest
public void EventTest ()
{
var service = new EventTestClass ();
var root = new Root (
new DeviceType ("schemas-upnp-org", "mono-upnp-test-device", new Version (1, 0)),
"uuid:d1",
"Mono.Upnp.Tests Device",
"Mono Project",
"Device",
new RootDeviceOptions {
Services = new[] {
new Service<EventTestClass> (
new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)),
"urn:upnp-org:serviceId:testService1",
service
)
}
}
);
var helper = new EventTestHelperClass (service, mutex);
using (var server = new Server (root)) {
using (var client = new Client ()) {
client.ServiceAdded += (sender, args) => {
try {
var controller = args.Service.GetService ().GetController ();
controller.StateVariables["FooChanged"].ValueChanged += helper.FirstEventHandler;
} catch (Exception e) {
helper.Exception = e;
lock (mutex) {
Monitor.Pulse (mutex);
}
}
};
client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)));
lock (mutex) {
server.Start ();
service.Foo = "Hello World!";
if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
Assert.Fail ("The event timed out.");
}
}
}
}
if (helper.Exception != null) {
throw helper.Exception;
}
}
示例3: BrowseAnnouncementExclusionTest
public void BrowseAnnouncementExclusionTest ()
{
using (var client = new Client ()) {
using (var server = new Server ()) {
client.ServiceAdded += (sender, args) => {
lock (mutex) {
if (args.Service.ServiceType != "upnp:test") {
Monitor.Pulse (mutex);
}
}
};
client.Browse ("upnp:test");
lock (mutex) {
server.Announce ("upnp:test:fail", "uuid:mono-upnp-tests:test1", "http://localhost/");
server.Announce ("upnp", "uuid:mono-upnp-tests:test2", "http://localhost/");
server.Announce ("upnp:test", "uuid:mono-upnp-tests:test3", "http://localhost/");
if (Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
Assert.Fail ("The client recieved invalid announcements.");
}
}
}
}
}
示例4: ControlTest
public void ControlTest ()
{
var root = new Root (
new DeviceType ("schemas-upnp-org", "mono-upnp-test-device", new Version (1, 0)),
"uuid:d1",
"Mono.Upnp.Tests Device",
"Mono Project",
"Device",
new RootDeviceOptions {
Services = new[] {
new Service<ControlTestClass> (
new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)),
"urn:upnp-org:serviceId:testService1",
new ControlTestClass ()
)
}
}
);
using (var client = new Client ()) {
client.Browse (new ServiceType ("schemas-upnp-org", "mono-upnp-test-service", new Version (1, 0)));
Exception exception = null;
client.ServiceAdded += (sender, args) => {
lock (mutex) {
try {
var controller = args.Service.GetService ().GetController ();
var arguments = new Dictionary<string, string> (1);
arguments["bar"] = "hello world!";
var results = controller.Actions["Foo"].Invoke (arguments);
Assert.AreEqual ("You said hello world!", results["result"]);
} catch (Exception e) {
exception = e;
} finally {
Monitor.Pulse (mutex);
}
}
};
using (var server = new Server (root)) {
lock (mutex) {
server.Start ();
if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
Assert.Fail ("The server control timed out.");
} else if (exception != null) {
throw exception;
}
}
}
}
}
示例5: BrowseAnnouncementInclusionTest
public void BrowseAnnouncementInclusionTest ()
{
using (var client = new Client ()) {
using (var server = new Server ()) {
client.ServiceAdded += ClientServiceAdded;
client.Browse ("upnp:test");
lock (mutex) {
server.Announce ("upnp:test", "uuid:mono-upnp-tests:test", "http://localhost/");
if (!Monitor.Wait (mutex, TimeSpan.FromSeconds (30))) {
Assert.Fail ("The announcement timed out.");
}
}
}
}
}