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


C# XmlResolver.ResolveUri方法代码示例

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


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

示例1: GetResolvedUri

		private string GetResolvedUri (XmlResolver resolver, string relativeUri)
		{
			Uri baseUri = null;
			if (this.SourceUri != null && this.SourceUri != String.Empty)
				baseUri = new Uri (this.SourceUri);
			Uri abs = resolver.ResolveUri (baseUri, relativeUri);
#if NET_2_0
			return abs != null ? abs.OriginalString : String.Empty;
#else
 			return abs != null ? abs.ToString () : String.Empty;
#endif
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:12,代码来源:XmlSchema.cs

示例2: UriEqual

 // SxS: URIs are resolved only to be compared. No resource exposure. It's OK to suppress the SxS warning.
 private bool UriEqual(Uri uri1, string uri1Str, string uri2Str, XmlResolver resolver)
 {
     if (resolver == null)
     {
         return uri1Str == uri2Str;
     }
     if (uri1 == null)
     {
         uri1 = resolver.ResolveUri(null, uri1Str);
     }
     Uri uri2 = resolver.ResolveUri(null, uri2Str);
     return uri1.Equals(uri2);
 }
开发者ID:chcosta,项目名称:corefx,代码行数:14,代码来源:XmlTextReaderImpl.cs

示例3: ReadXml

        public void ReadXml(XPathNavigator node, XmlResolver resolver)
        {
            if (node.NodeType == XPathNodeType.Element) {

            XPathNavigator el = node.Clone();

            if (node.MoveToFirstAttribute()) {

               do {
                  switch (node.LocalName) {
                     case "byte-order-mark":
                        this.ByteOrderMark = node.ValueAsBoolean;
                        break;

                     case "doctype-public":
                        this.DocTypePublic = node.Value;
                        break;

                     case "doctype-system":
                        this.DocTypeSystem = node.Value;
                        break;

                     case "encoding":
                        this.Encoding = Encoding.GetEncoding(node.Value);
                        break;

                     case "indent":
                        this.Indent = node.ValueAsBoolean;
                        break;

                     case "media-type":
                        this.MediaType = node.Value;
                        break;

                     case "method":

                        if (node.Value.Contains(":")) {

                           string name = XmlConvert.VerifyName(node.Value);
                           string[] parts = name.Split(':');

                           string local = parts[1];
                           string ns = node.LookupNamespace(parts[0]) ?? "";

                           XmlQualifiedName qname = new XmlQualifiedName(local, ns);

                           if (ns != null
                              && (qname == ExtensionMethods.Base64Binary
                                 || qname == ExtensionMethods.HexBinary)) {
                              this.Method = qname;
                           } else {
                              throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
                           }

                        } else {

                           switch (node.Value) {
                              case "xml":
                                 this.Method = XPathSerializationMethods.Xml;
                                 break;

                              case "html":
                                 this.Method = XPathSerializationMethods.Html;
                                 break;

                              case "xhtml":
                                 this.Method = XPathSerializationMethods.XHtml;
                                 break;

                              case "text":
                                 this.Method = XPathSerializationMethods.Text;
                                 break;

                              default:
                                 throw new ArgumentException("The value of the method attribute must be one of: xml, html, xhtml, text, http:base64Binary or http:hexBinary.", "node");
                           }
                        }
                        break;

                     case "omit-xml-declaration":
                        this.OmitXmlDeclaration = node.ValueAsBoolean;
                        break;

                     case "src":

                        Uri elBaseUri = !String.IsNullOrEmpty(el.BaseURI) ?
                           new Uri(el.BaseURI) :
                           null;

                        if (resolver != null) {
                           this.Src = resolver.ResolveUri(elBaseUri, node.Value);
                        } else {
                           this.Src = (elBaseUri != null) ?
                              new Uri(elBaseUri, node.Value) :
                              new Uri(node.Value);
                        }

                        break;

                     default:
//.........这里部分代码省略.........
开发者ID:skurdiukov,项目名称:myxsl,代码行数:101,代码来源:XPathHttpBody.cs

示例4: XmlTextReaderImpl

        // Initializes a new instance of the XmlTextReaderImpl class with the specified arguments.
        // This constructor is used when creating XmlTextReaderImpl via XmlReader.Create
        internal XmlTextReaderImpl(string uriStr, XmlReaderSettings settings, XmlParserContext context, XmlResolver uriResolver)
            : this(settings.GetXmlResolver(), settings, context)
        {
            Uri baseUri = uriResolver.ResolveUri(null, uriStr);
            string baseUriStr = baseUri.ToString();

            // get BaseUri from XmlParserContext
            if (context != null)
            {
                if (context.BaseURI != null && context.BaseURI.Length > 0 &&
                    !UriEqual(baseUri, baseUriStr, context.BaseURI, settings.GetXmlResolver()))
                {
                    if (baseUriStr.Length > 0)
                    {
                        Throw(SR.Xml_DoubleBaseUri);
                    }
                    Debug.Assert(baseUri == null);
                    baseUriStr = context.BaseURI;
                }
            }

            _reportedBaseUri = baseUriStr;
            _closeInput = true;
            _laterInitParam = new LaterInitParam();
            _laterInitParam.inputUriStr = uriStr;
            _laterInitParam.inputbaseUri = baseUri;
            _laterInitParam.inputContext = context;
            _laterInitParam.inputUriResolver = uriResolver;
            _laterInitParam.initType = InitInputType.UriString;
            if (!settings.Async)
            {
                //if not set Async flag, finish the init in create stage.
                FinishInitUriString();
            }
            else
            {
                _laterInitParam.useAsync = true;
            }
        }
开发者ID:chcosta,项目名称:corefx,代码行数:41,代码来源:XmlTextReaderImpl.cs

示例5: LoadDoc

 public static XPathDocument LoadDoc(string name, XmlResolver resolver){
     var uri = resolver.ResolveUri(null, name);
     var s = resolver.GetEntity(uri, "", typeof (Stream)) as Stream;
     return GetDoc(s);
 }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:5,代码来源:XmlUtil.cs


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