Ejemplo n.º 1
0
        public void AddProperty()
        {
            var service = new ServiceProfile
            {
                InstanceName = "x",
                ServiceName  = "_sdtest._udp"
            };

            service.AddProperty("a", "1");

            var txt = service.Resources.OfType <TXTRecord>().First();

            Assert.AreEqual(service.FullyQualifiedName, txt.Name);
            CollectionAssert.Contains(txt.Strings, "a=1");
        }
Ejemplo n.º 2
0
        public void ResourceRecords()
        {
            var profile = new ServiceProfile("me", "_myservice._udp", 1234, new IPAddress[] { IPAddress.Loopback });

            profile.Subtypes.Add("apiv2");
            profile.AddProperty("someprop", "somevalue");

            using (var sd = new ServiceDiscovery())
            {
                sd.Advertise(profile);

                var resourceRecords = sd.NameServer.Catalog.Values.SelectMany(node => node.Resources);
                foreach (var r in resourceRecords)
                {
                    Console.WriteLine(r.ToString());
                }
            }
        }