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


C# MetadataSet.WriteTo方法代码示例

本文整理汇总了C#中System.ServiceModel.Description.MetadataSet.WriteTo方法的典型用法代码示例。如果您正苦于以下问题:C# MetadataSet.WriteTo方法的具体用法?C# MetadataSet.WriteTo怎么用?C# MetadataSet.WriteTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.ServiceModel.Description.MetadataSet的用法示例。


在下文中一共展示了MetadataSet.WriteTo方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriterMetadata

 private static void WriterMetadata(MetadataSet metadata)
 {
     using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
     {
         metadata.WriteTo(writer);
     }
     Process.Start("metadata.xml");
 }
开发者ID:gauge2009,项目名称:RPC,代码行数:8,代码来源:Program.cs

示例2: Main

 static void Main(string[] args)
 {
     MetadataSet metadata = new MetadataSet();
     string address = "http://127.0.0.1:3721/calculatorservice/metadata";
     HttpWebRequest request = (HttpWebRequest)WebRequest.Create(address);
     request.Method = "Get";
     HttpWebResponse response = (HttpWebResponse)request.GetResponse();
     using (XmlReader reader = XmlDictionaryReader.CreateTextReader(response.GetResponseStream(), new XmlDictionaryReaderQuotas()))
     {
         System.Web.Services.Description.ServiceDescription serviceDesc = System.Web.Services.Description.ServiceDescription.Read(reader);
         metadata.MetadataSections.Add(MetadataSection.CreateFromServiceDescription(serviceDesc));
     }
     using (XmlWriter writer = new XmlTextWriter("metadata.xml", Encoding.UTF8))
     {
         metadata.WriteTo(writer);
     }
     Process.Start("metadata.xml");
 }
开发者ID:huoxudong125,项目名称:WCF-Demo,代码行数:18,代码来源:Program.cs

示例3: CreateMetadataReader

        private XmlDictionaryReader CreateMetadataReader(Uri mexAddress)
        {
            var metadataSet = new MetadataSet();
            var metadataReference = new MetadataReference(new EndpointAddress(mexAddress),
                AddressingVersion.WSAddressing10);
            var metadataSection = new MetadataSection(MetadataSection.MetadataExchangeDialect, null, metadataReference);
            metadataSet.MetadataSections.Add(metadataSection);

            var sb = new StringBuilder();
            var w = new StringWriter(sb, CultureInfo.InvariantCulture);
            var writer = XmlWriter.Create(w);

            metadataSet.WriteTo(writer);
            writer.Flush();
            w.Flush();

            var input = new StringReader(sb.ToString());
            var reader = new XmlTextReader(input);
            return XmlDictionaryReader.CreateDictionaryReader(reader);
        }
开发者ID:azhuang88,项目名称:IdentityServer,代码行数:20,代码来源:WSFederationMetadataGenerator.cs

示例4: CreateWsspIssuerElement

        public virtual XmlElement CreateWsspIssuerElement(EndpointAddress issuerAddress, EndpointAddress issuerMetadataAddress)
        {
            XmlElement result;
            if (issuerAddress == null && issuerMetadataAddress == null)
            {
                result = null;
            }
            else
            {
                EndpointAddress addressToSerialize;
                addressToSerialize = issuerAddress == null ? EndpointAddress.AnonymousAddress : issuerAddress;

                MemoryStream stream;
                XmlWriter writer;

                if (issuerMetadataAddress != null)
                {
                    MetadataSet metadataSet = new MetadataSet();
                    metadataSet.MetadataSections.Add(new MetadataSection(null, null, new MetadataReference(issuerMetadataAddress, AddressingVersion.WSAddressing10)));

                    stream = new MemoryStream();
                    writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
                    metadataSet.WriteTo(XmlDictionaryWriter.CreateDictionaryWriter(writer));
                    writer.Flush();
                    stream.Seek(0, SeekOrigin.Begin);

                    addressToSerialize = new EndpointAddress(
                        addressToSerialize.Uri,
                        addressToSerialize.Identity,
                        addressToSerialize.Headers,
                        XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(stream)),
                        addressToSerialize.GetReaderAtExtensions());
                }

                stream = new MemoryStream();
                writer = new XmlTextWriter(stream, System.Text.Encoding.UTF8);
                writer.WriteStartElement(IssuerName, this.WsspNamespaceUri);
                addressToSerialize.WriteContentsTo(AddressingVersion.WSAddressing10, writer);
                writer.WriteEndElement();
                writer.Flush();
                stream.Seek(0, SeekOrigin.Begin);
                result = (XmlElement)doc.ReadNode(new XmlTextReader(stream));
            }
            return result;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:45,代码来源:WSSecurityPolicy.cs

示例5: SerializeAndSign

        /// <summary>
        /// Sign this information card and write it to a file.
        /// </summary>
        /// <param name="filename">Path to where this card should be stored.</param>
        /// <param name="cert">Certificate to use for signing this card.</param>
        public void SerializeAndSign( string filename, X509Certificate2 cert )
        {
            MemoryStream stream = new MemoryStream();
            XmlWriter writer = XmlWriter.Create( stream );

            writer.WriteStartElement( XmlNames.WSIdentity.InfoCardElement, XmlNames.WSIdentity.Namespace );

            //
            // write the InformationCardReference element
            //
            writer.WriteAttributeString( XmlNames.Xml.Language, XmlNames.Xml.Namespace, m_language );
            writer.WriteStartElement( XmlNames.WSIdentity.InfoCardRefElement, XmlNames.WSIdentity.Namespace );
            writer.WriteElementString( XmlNames.WSIdentity.CardIdElement, XmlNames.WSIdentity.Namespace, m_cardId );
            writer.WriteElementString( XmlNames.WSIdentity.CardVersionElement, XmlNames.WSIdentity.Namespace, m_cardVersion );
            writer.WriteEndElement();

            //
            // card name
            //
            if( !String.IsNullOrEmpty( m_cardName ) )
            {
                writer.WriteStartElement( XmlNames.WSIdentity.CardNameElement, XmlNames.WSIdentity.Namespace );
                writer.WriteString( m_cardName );
                writer.WriteEndElement();
            }

            //
            // card image
            //
            if( null != m_logo && 0 != m_logo.Length )
            {
                writer.WriteStartElement( XmlNames.WSIdentity.CardImageElement, XmlNames.WSIdentity.Namespace );
                if( !String.IsNullOrEmpty( m_mimeType ) )
                {
                    writer.WriteAttributeString( XmlNames.WSIdentity.MimeTypeAttribute, m_mimeType );
                }
                string val = Convert.ToBase64String( m_logo );
                writer.WriteString( val );
                writer.WriteEndElement();
            }

            //
            // card issuer uri
            //
            writer.WriteStartElement( XmlNames.WSIdentity.IssuerElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( m_issuerId );
            writer.WriteEndElement();

            //
            // issue time
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TimeIssuedElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( XmlConvert.ToString( m_issuedOn, XmlDateTimeSerializationMode.Utc ) );
            writer.WriteEndElement();

            //
            // expiry time
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TimeExpiresElement, XmlNames.WSIdentity.Namespace );
            writer.WriteString( XmlConvert.ToString( m_expiresOn, XmlDateTimeSerializationMode.Utc ) );
            writer.WriteEndElement();

            //
            // Start the tokenservice list
            //
            writer.WriteStartElement( XmlNames.WSIdentity.TokenServiceListElement, XmlNames.WSIdentity.Namespace );

            EndpointAddressBuilder eprBuilder = new EndpointAddressBuilder();

            eprBuilder.Uri = new Uri( m_issuerId );

            eprBuilder.Identity = new X509CertificateEndpointIdentity( cert );

            if( null != m_mexUri )
            {

                MetadataReference mexRef = new MetadataReference();
                mexRef.Address = new EndpointAddress( m_mexUri );
                mexRef.AddressVersion = AddressingVersion.WSAddressing10;

                MetadataSection mexSection = new MetadataSection();
                mexSection.Metadata = mexRef;

                MetadataSet mexSet = new MetadataSet();
                mexSet.MetadataSections.Add( mexSection );

                MemoryStream memStream = new MemoryStream();

                XmlTextWriter writer1 = new XmlTextWriter( memStream, System.Text.Encoding.UTF8 );

                mexSet.WriteTo( writer1 );

                writer1.Flush();

                memStream.Seek( 0, SeekOrigin.Begin );
//.........这里部分代码省略.........
开发者ID:hernandazevedo,项目名称:JMRTD,代码行数:101,代码来源:ManagedInformationCard.cs

示例6: CreateWsspIssuerElement

 public virtual XmlElement CreateWsspIssuerElement(EndpointAddress issuerAddress, EndpointAddress issuerMetadataAddress)
 {
     MemoryStream stream;
     XmlWriter writer;
     if ((issuerAddress == null) && (issuerMetadataAddress == null))
     {
         return null;
     }
     EndpointAddress address = (issuerAddress == null) ? EndpointAddress.AnonymousAddress : issuerAddress;
     if (issuerMetadataAddress != null)
     {
         MetadataSet set = new MetadataSet {
             MetadataSections = { new MetadataSection(null, null, new MetadataReference(issuerMetadataAddress, AddressingVersion.WSAddressing10)) }
         };
         stream = new MemoryStream();
         writer = new XmlTextWriter(stream, Encoding.UTF8);
         set.WriteTo(XmlDictionaryWriter.CreateDictionaryWriter(writer));
         writer.Flush();
         stream.Seek(0L, SeekOrigin.Begin);
         address = new EndpointAddress(address.Uri, address.Identity, address.Headers, XmlDictionaryReader.CreateDictionaryReader(XmlReader.Create(stream)), address.GetReaderAtExtensions());
     }
     stream = new MemoryStream();
     writer = new XmlTextWriter(stream, Encoding.UTF8);
     writer.WriteStartElement("Issuer", this.WsspNamespaceUri);
     address.WriteContentsTo(AddressingVersion.WSAddressing10, writer);
     writer.WriteEndElement();
     writer.Flush();
     stream.Seek(0L, SeekOrigin.Begin);
     return (XmlElement) doc.ReadNode(new XmlTextReader(stream));
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:WSSecurityPolicy.cs

示例7: Save

 public static void Save(string filename, MetadataSet metadata)
 {
     using (var file = new StreamWriter (filename, false)) {
         var writer = new XmlTextWriter (file);
         writer.Formatting = Formatting.Indented;
         metadata.WriteTo (writer);
     }
 }
开发者ID:baulig,项目名称:Provcon-Faust,代码行数:8,代码来源:Utils.cs

示例8: CreateMetadataReader

        private static XmlDictionaryReader CreateMetadataReader(Uri mexAddress)
        {
            var metadataSet = new MetadataSet();
            var metadataReference = new MetadataReference(new EndpointAddress(mexAddress), AddressingVersion.WSAddressing10);
            var metadataSection = new MetadataSection(MetadataSection.MetadataExchangeDialect, null, metadataReference);
            metadataSet.MetadataSections.Add(metadataSection);

            var stringBuilder = new StringBuilder();
            using(var stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
            {
                var xmlWriter = XmlWriter.Create(stringWriter);
                metadataSet.WriteTo(xmlWriter);
                xmlWriter.Flush();
                stringWriter.Flush();

                var stringReader = new StringReader(stringBuilder.ToString());
                var xmlTextReader = new XmlTextReader(stringReader);
                var result = XmlDictionaryReader.CreateDictionaryReader(xmlTextReader);
                return result;
            }
        }
开发者ID:colinbowern,项目名称:TwoTierSts,代码行数:21,代码来源:FederationMetadataController.cs

示例9: GetMetadataReader

        /// <summary>
        /// Create a reader to provide simulated Metadata endpoint configuration element
        /// </summary>
        /// <param name="activeSTSUrl">The active endpoint URL.</param>
        static XmlDictionaryReader GetMetadataReader(string activeSTSUrl)
        {
            MetadataSet metadata = new MetadataSet();
            MetadataReference mexReferece = new MetadataReference(new EndpointAddress(activeSTSUrl), AddressingVersion.WSAddressing10);
            MetadataSection refSection = new MetadataSection(MetadataSection.ServiceDescriptionDialect, null, mexReferece);
            metadata.MetadataSections.Add(refSection);

            byte[] metadataSectionBytes;
            StringBuilder stringBuilder = new StringBuilder();
            using (StringWriter stringWriter = new StringWriter(stringBuilder))
            {
                using (XmlTextWriter textWriter = new XmlTextWriter(stringWriter))
                {
                    metadata.WriteTo(textWriter);
                    textWriter.Flush();
                    stringWriter.Flush();
                    metadataSectionBytes = stringWriter.Encoding.GetBytes(stringBuilder.ToString());
                }
            }

            return XmlDictionaryReader.CreateTextReader(metadataSectionBytes, XmlDictionaryReaderQuotas.Max);
        }
开发者ID:juanonsoftware,项目名称:practices,代码行数:26,代码来源:Common.cs


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