Esempio n. 1
0
        public void UsageExample()
        {
            var eb = new EndpointAddressBuilder();
            var dr = XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(new StringReader("<foo/>")));

            eb.SetExtensionReader(dr);
            Assert.AreEqual(ReadState.EndOfFile, dr.ReadState, "#1");
            var xr = eb.GetReaderAtExtensions();

            xr.ReadOuterXml();
            xr = eb.GetReaderAtExtensions();              // do not return the same XmlReader
            Assert.AreEqual(ReadState.Interactive, xr.ReadState, "#2");
            xr.ReadOuterXml();
            eb.SetExtensionReader(null);              // allowed
            Assert.IsNull(eb.GetReaderAtExtensions(), "#3");
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            // <Snippet0>
            // <Snippet3>
            // <Snippet1>
            EndpointAddressBuilder eab = new EndpointAddressBuilder();

            // </Snippet1>
            eab.Uri = new Uri("http://localhost/Uri");
            eab.Headers.Add(AddressHeader.CreateAddressHeader("n", "ns", "val"));
            // </Snippet3>

            // <Snippet4>
            eab.Identity = EndpointIdentity.CreateUpnIdentity("identity");
            // </Snippet4>

            // <Snippet5>
            XmlDictionaryReader xdrExtensions = eab.GetReaderAtExtensions();
            // </Snippet5>

            // <Snippet6>
            StringReader sr = new StringReader(@"<myExtension xmlns=""myExtNs"" />");

            eab.SetExtensionReader(XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(sr)));
            // </Snippet6>

            // <Snippet7>
            EndpointAddress ea = eab.ToEndpointAddress();

            // </Snippet7>

            // <Snippet8>
            sr = new StringReader(@"<myMetadata xmlns=""myMetaNs"" />");
            XmlDictionaryReader xdrMetaData = eab.GetReaderAtMetadata();

            // </Snippet8>

            // <Snippet9>
            eab.SetMetadataReader(XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(sr)));
            // </Snippet9>
            // </Snippet0>

            // <Snippet2>
            EndpointAddress        endpointAddress = new EndpointAddress("http://localhost/uri2");
            EndpointAddressBuilder eab2            = new EndpointAddressBuilder(endpointAddress);
            // </Snippet2>
        }