当前位置: 首页>>代码示例>>C#>>正文


C# Client.Browse方法代码示例

本文整理汇总了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);
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:29,代码来源:ClientTests.cs

示例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;
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:47,代码来源:ClientTests.cs

示例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.");
                 }
             }
         }
     }
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:23,代码来源:ClientTests.cs

示例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;
                 }
             }
         }
     }
 }
开发者ID:rsweeney21,项目名称:Mono.Upnp,代码行数:50,代码来源:ClientTests.cs

示例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.");
                 }
             }
         }
     }
 }
开发者ID:pacificIT,项目名称:mono-upnp,代码行数:15,代码来源:ClientTests.cs


注:本文中的Client.Browse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。