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


C# IXmlNamespaceResolver.LookupNamespace方法代码示例

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


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

示例1: Parse

        internal static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix)
        {
            string localName;
            ValidateNames.ParseQNameThrow(s, out prefix, out localName);

            string uri = nsmgr.LookupNamespace(prefix);
            if (uri == null)
            {
                if (prefix.Length != 0)
                {
                    throw new XmlException(SR.Xml_UnknownNs, prefix);
                }
                else
                { //Re-map namespace of empty prefix to string.Empty when there is no default namespace declared
                    uri = string.Empty;
                }
            }
            return new XmlQualifiedName(localName, uri);
        }
开发者ID:Corillian,项目名称:corefx,代码行数:19,代码来源:XmlQualifiedName.cs

示例2: XmlWellFormedWriter

        //
        // Constructor & finalizer
        //
        internal XmlWellFormedWriter(XmlWriter writer, XmlWriterSettings settings)
        {
            Debug.Assert(writer != null);
            Debug.Assert(settings != null);
            Debug.Assert(MaxNamespacesWalkCount <= 3);

            _writer = writer;

            _rawWriter = writer as XmlRawWriter;
            _predefinedNamespaces = writer as IXmlNamespaceResolver;
            if (_rawWriter != null)
            {
                _rawWriter.NamespaceResolver = new NamespaceResolverProxy(this);
            }

            _checkCharacters = settings.CheckCharacters;
            _omitDuplNamespaces = (settings.NamespaceHandling & NamespaceHandling.OmitDuplicates) != 0;
            _writeEndDocumentOnClose = settings.WriteEndDocumentOnClose;

            _conformanceLevel = settings.ConformanceLevel;
            _stateTable = (_conformanceLevel == ConformanceLevel.Document) ? s_stateTableDocument : s_stateTableAuto;

            _currentState = State.Start;

            _nsStack = new Namespace[NamespaceStackInitialSize];
            _nsStack[0].Set("xmlns", XmlReservedNs.NsXmlNs, NamespaceKind.Special);
            _nsStack[1].Set("xml", XmlReservedNs.NsXml, NamespaceKind.Special);
            if (_predefinedNamespaces == null)
            {
                _nsStack[2].Set(string.Empty, string.Empty, NamespaceKind.Implied);
            }
            else
            {
                string defaultNs = _predefinedNamespaces.LookupNamespace(string.Empty);
                _nsStack[2].Set(string.Empty, (defaultNs == null ? string.Empty : defaultNs), NamespaceKind.Implied);
            }
            _nsTop = 2;

            _elemScopeStack = new ElementScope[ElementStackInitialSize];
            _elemScopeStack[0].Set(string.Empty, string.Empty, string.Empty, _nsTop);
            _elemScopeStack[0].xmlSpace = XmlSpace.None;
            _elemScopeStack[0].xmlLang = null;
            _elemTop = 0;

            _attrStack = new AttrName[AttributeArrayInitialSize];

            _hasher = new SecureStringHasher();
        }
开发者ID:shiftkey-tester,项目名称:corefx,代码行数:51,代码来源:XmlWellformedWriter.cs

示例3: StringToQName

        private static XmlQualifiedName StringToQName(string value, IXmlNamespaceResolver nsResolver)
        {
            string prefix, localName, ns;

            value = value.Trim();

            // Parse prefix:localName
            try
            {
                ValidateNames.ParseQNameThrow(value, out prefix, out localName);
            }
            catch (XmlException e)
            {
                throw new FormatException(e.Message);
            }

            // Throw error if no namespaces are in scope
            if (nsResolver == null)
                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoNamespace, value, prefix));

            // Lookup namespace
            ns = nsResolver.LookupNamespace(prefix);
            if (ns == null)
                throw new InvalidCastException(SR.Format(SR.XmlConvert_TypeNoNamespace, value, prefix));

            // Create XmlQualfiedName
            return new XmlQualifiedName(localName, ns);
        }
开发者ID:svcgany1,项目名称:corefx,代码行数:28,代码来源:XmlUntypedConverter.cs

示例4: ParseQName

		// Methods

		public static XmlQualifiedName ParseQName (string name, IXmlNamespaceResolver resolver)
		{
			int index = name.IndexOf (':');
			if (index < 0)
				return new XmlQualifiedName (name);
			string ns = resolver.LookupNamespace (name.Substring (0, index));
			if (ns == null)
				throw new ArgumentException ("Invalid qualified name.");
			return new XmlQualifiedName (name.Substring (index + 1), ns);
		}
开发者ID:nlhepler,项目名称:mono,代码行数:12,代码来源:InternalPool.cs

示例5: Parse

		internal static XmlQualifiedName Parse (string name, IXmlNamespaceResolver resolver, bool considerDefaultNamespace)
		{
			int index = name.IndexOf (':');
			if (index < 0 && !considerDefaultNamespace)
				return new XmlQualifiedName (name);
			string prefix = index < 0 ? String.Empty : name.Substring (0, index);
			string localName = index < 0 ? name : name.Substring (index + 1);
			string ns = resolver.LookupNamespace (prefix);
			if (ns == null) {
				if (prefix.Length > 0)
					throw new ArgumentException ("Invalid qualified name.");
				else
					ns = String.Empty;
			}
			return new XmlQualifiedName (localName, ns);
		}
开发者ID:nobled,项目名称:mono,代码行数:16,代码来源:XmlQualifiedName.cs

示例6: XmlAtomicValue

 internal XmlAtomicValue(XmlSchemaType xmlType, string value, IXmlNamespaceResolver nsResolver)
 {
     if (value == null) throw new ArgumentNullException(nameof(value));
     if (xmlType == null) throw new ArgumentNullException(nameof(xmlType));
     _xmlType = xmlType;
     _objVal = value;
     if (nsResolver != null && (_xmlType.TypeCode == XmlTypeCode.QName || _xmlType.TypeCode == XmlTypeCode.Notation))
     {
         string prefix = GetPrefixFromQName(value);
         _nsPrefix = new NamespacePrefixForQName(prefix, nsResolver.LookupNamespace(prefix));
     }
 }
开发者ID:Corillian,项目名称:corefx,代码行数:12,代码来源:XmlAtomicValue.cs

示例7: GenerateNewElement

        private static XElement GenerateNewElement(string name, IXmlNamespaceResolver resolver)
        {
            XName newElementName = null;
            if (name.Contains(XPathExtensions.namespaceSeparator))
            {
                if (resolver == null) throw new ArgumentNullException("resolver", "Es wurde keine NamespaceResolver angegeben.");

                var splittedName = name.Split(new [] { XPathExtensions.namespaceSeparator }, StringSplitOptions.None);

                var namespacePraefix = splittedName.Length > 1 ? splittedName[0] : string.Empty;
                var elementName = splittedName.Length > 1 ? splittedName[1] : splittedName[0];

                XNamespace nameSpace = resolver.LookupNamespace(namespacePraefix);
                if (string.IsNullOrEmpty(nameSpace.NamespaceName))
                {
                    throw new InvalidOperationException(string.Format("Es wurde kein Nampespace mit dem Präfix \"{0}\" gefunden.", namespacePraefix));
                }
                newElementName = nameSpace + elementName;
            }
            else
            {
                if(resolver != null)
                {
                    throw new XPathException("Das Element konnte nicht erstellt werden. Es fehlt ein entsprechender Namespace im Pfad.");
                }

                newElementName = name;
            }

            // Neues Element wird erstellt
            return new XElement(newElementName);
        }
开发者ID:LegendOfGIT,项目名称:knowledge,代码行数:32,代码来源:XPathExtensions.cs

示例8: Matches

		public override bool Matches(XmlReader reader, IXmlNamespaceResolver resolver)
		{
			bool nsMatches = IsAnyNamespace;
			bool nameMatches = IsAnyName;

			if (!nsMatches)
			{
				string ns = String.Empty;
				if (prefix.Length > 0)
				{
					if (resolver == null)
					{
						throw new ArgumentException(Properties.Resources.NamespaceResolverRequired, "resolver");
					}

					ns = resolver.LookupNamespace(prefix);

					if (ns == null)
					{
						throw new ArgumentException(String.Format(
							CultureInfo.CurrentCulture,
							Properties.Resources.CannotResolvePrefix,
							prefix));
					}
				}

				nsMatches = (ns == reader.NamespaceURI);
			}

			if (!nameMatches)
			{
				nameMatches = (name == reader.LocalName);
			}

			return nsMatches && nameMatches;
		}
开发者ID:zanyants,项目名称:mvp.xml,代码行数:36,代码来源:XmlNameMatch.cs

示例9: Parse

 internal static XmlQualifiedName Parse(string s, IXmlNamespaceResolver nsmgr, out string prefix)
 {
     string str;
     ValidateNames.ParseQNameThrow(s, out prefix, out str);
     string ns = nsmgr.LookupNamespace(prefix);
     if (ns == null)
     {
         if (prefix.Length != 0)
         {
             throw new XmlException("Xml_UnknownNs", prefix);
         }
         ns = string.Empty;
     }
     return new XmlQualifiedName(str, ns);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:XmlQualifiedName.cs

示例10: ParseQName

 // Parse a QName from the string, and resolve prefix
 XmlQualifiedName ParseQName(string xpath, ref int pos, IXmlNamespaceResolver xnr) {
     string nm = ParseName(xpath, ref pos);
     if (pos < xpath.Length && ':' == xpath[pos]) {
         pos++;
         string ns = (null==xnr) ? null : xnr.LookupNamespace(nm);
         if (null == ns || 0 == ns.Length)
             throw new XmlException(Res.Sch_UnresolvedPrefix, nm);
         return new XmlQualifiedName(ParseName(xpath, ref pos), ns);
     }
     else {
         return new XmlQualifiedName(nm);
     }
 }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:14,代码来源:xpathdocumentview.cs

示例11: XmlAtomicValue

 internal XmlAtomicValue(XmlSchemaType xmlType, string value, IXmlNamespaceResolver nsResolver)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (xmlType == null)
     {
         throw new ArgumentNullException("xmlType");
     }
     this.xmlType = xmlType;
     this.objVal = value;
     if ((nsResolver != null) && ((this.xmlType.TypeCode == XmlTypeCode.QName) || (this.xmlType.TypeCode == XmlTypeCode.Notation)))
     {
         string prefixFromQName = this.GetPrefixFromQName(value);
         this.nsPrefix = new NamespacePrefixForQName(prefixFromQName, nsResolver.LookupNamespace(prefixFromQName));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:18,代码来源:XmlAtomicValue.cs

示例12: Clean


//.........这里部分代码省略.........
            foreach (var item in items.Where(e => !e.IsEmpty && !e.HasElements))
            {
                item.RemoveNodes();
            }
            #endregion

            #region Clean up References
            proj.XPathSelectElements("//build:Reference[@Include='System.configuration']", ns).Attributes("Include").SetValue("System.Configuration");
            proj.XPathSelectElements("//build:Reference[@Include='System.XML']", ns).Attributes("Include").SetValue("System.Xml");

            proj.XPathSelectElements("//build:AssemblyFolderKey", ns).Remove();
            proj.XPathSelectElements("//build:SpecificVersion", ns).Remove();
            proj.XPathSelectElements("//build:ReferencePath", ns).Remove();
            proj.XPathSelectElements("//build:CurrentPlatform", ns).Remove();
            proj.XPathSelectElements("//build:Reference/build:Name", ns).Remove();
            proj.XPathSelectElements("//build:Reference/build:RequiredTargetFramework", ns).Remove();

            var referenceParent = proj.XPathSelectElements("//build:ItemGroup[build:Reference]", ns).FirstOrDefault();
            if (referenceParent != null)
            {
                proj.XPathSelectElements("//build:Reference", ns).OrderBy(c => c.Attribute("Include").Value.SubstringTill(',').Replace("System", "aaaaaaa")).Reparent(referenceParent);
            }
            #endregion

            #region Clean up ProjectReferences
            proj.XPathSelectElements("//build:ProjectReference/build:Package", ns).Remove();

            proj.XPathSelectElements("//build:ProjectReference[@Include]/build:Name", ns).SetValue(n => Path.GetFileNameWithoutExtension(n.Parent.Attribute("Include").Value));
            foreach (var name in proj.XPathSelectElements("//build:ProjectReference[@Include]/build:Name", ns))
            {
                var parent = name.Parent;
                name.Remove();
                parent.AddFirst(name);
            }

            var projectReferenceParent = proj.XPathSelectElements("//build:ItemGroup[build:ProjectReference]", ns).FirstOrDefault();
            if (projectReferenceParent != null)
            {
                proj.XPathSelectElements("//build:ProjectReference", ns).OrderBy(c => c.Element(XName.Get("Name", ns.LookupNamespace("build"))).Value).Reparent(projectReferenceParent);
            }

            var imports = proj.XPathSelectElements("//build:Import[starts-with(@Project, '..')]", ns).ToArray();
            foreach (var import in imports)
            {
                var path = import.Attribute("Project").Value;
                import.SetAttributeValue("Condition", String.Format("Exists('{0}')", path));

                continue;
            }
            #endregion

            #region Clean up Web Projects
            proj.XPathSelectElements("//build:SaveServerSettingsInUserFile", ns).SetValue(true);

            proj.XPathSelectElements("//build:WebProjectProperties/build:UseIIS", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:AutoAssignPort", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:DevelopmentServerPort", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:DevelopmentServerVPath", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:IISUrl", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:NTLMAuthentication", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:UseCustomServer", ns).Remove();
            proj.XPathSelectElements("//build:WebProjectProperties/build:CustomServerUrl", ns).Remove();
            #endregion

            #region Clean up PreBuildEvent/PostBuildEvent
            proj.XPathSelectElements("//build:PostBuildEvent", ns).Where(e => e.Value.IndexOf("sn.exe", StringComparison.CurrentCultureIgnoreCase) >= 0).SetValue("");

            proj.XPathSelectElements("//build:PreBuildEvent", ns).Where(e => String.IsNullOrWhiteSpace(e.Value)).Remove();
            proj.XPathSelectElements("//build:PostBuildEvent", ns).Where(e => String.IsNullOrWhiteSpace(e.Value)).Remove();

            if (!proj.XPathSelectElements("//build:PreBuildEvent", ns).Any(e => String.IsNullOrWhiteSpace(e.Value)))
                proj.XPathSelectElements("//build:RunPreBuildEvent", ns).Remove();

            if (!proj.XPathSelectElements("//build:PostBuildEvent", ns).Any(e => String.IsNullOrWhiteSpace(e.Value)))
                proj.XPathSelectElements("//build:RunPostBuildEvent", ns).Remove();
            #endregion

            #region Configure signing
            var canSign = !String.IsNullOrEmpty(relativeSigningKeyPath);

            proj.XPathSelectElements("//build:SignAssembly", ns).Remove();
            proj.XPathSelectElements("//build:DelaySign", ns).Remove();
            proj.XPathSelectElements("//build:AssemblyOriginatorKeyFile", ns).Remove();
            proj.XPathSelectElements("//build:AssemblyKeyContainerName", ns).Remove();

            if (mainPG != null)
            {
                mainPG.AddElement("SignAssembly", content: canSign);
                if (canSign)
                {
                    mainPG.AddElement("DelaySign", content: false);

                    mainPG.AddElement("AssemblyOriginatorKeyFile", content: relativeSigningKeyPath);
                }
            }
            #endregion

            proj.XPathSelectElements("//build:PropertyGroup", ns).Where(e => !e.Nodes().Any()).Remove();
            proj.XPathSelectElements("//build:ItemGroup", ns).Where(e => !e.Nodes().Any()).Remove();
        }
开发者ID:superstrom,项目名称:SolutionCleaner,代码行数:101,代码来源:CSProjCleaner.cs

示例13: XmlWellFormedWriter

        //
        // Constructor & finalizer
        //
        internal XmlWellFormedWriter(XmlWriter writer, XmlWriterSettings settings) {
            Debug.Assert(writer != null);
            Debug.Assert(settings != null);
            Debug.Assert(MaxNamespacesWalkCount <= 3);

            this.writer = writer;

            rawWriter = writer as XmlRawWriter;
            predefinedNamespaces = writer as IXmlNamespaceResolver;
            if (rawWriter != null) {
                rawWriter.NamespaceResolver = new NamespaceResolverProxy(this);
            }

            checkCharacters = settings.CheckCharacters;

            conformanceLevel = settings.ConformanceLevel;
            stateTable = (conformanceLevel == ConformanceLevel.Document) ? StateTableDocument : StateTableAuto;

            currentState = State.Start;

            nsStack = new Namespace[NamespaceStackInitialSize];
            nsStack[0].Set("xmlns", XmlReservedNs.NsXmlNs, NamespaceKind.Special);
            nsStack[1].Set("xml", XmlReservedNs.NsXml, NamespaceKind.Special);
            if (predefinedNamespaces == null) {
                nsStack[2].Set(string.Empty, string.Empty, NamespaceKind.Implied);
            }
            else {
                string defaultNs = predefinedNamespaces.LookupNamespace(string.Empty);
                nsStack[2].Set(string.Empty, (defaultNs == null ? string.Empty : defaultNs), NamespaceKind.Implied);
            }
            nsTop = 2;

            elemScopeStack = new ElementScope[ElementStackInitialSize];
            elemScopeStack[0].Set(string.Empty, string.Empty, string.Empty, nsTop);
            elemScopeStack[0].xmlSpace = XmlSpace.None;
            elemScopeStack[0].xmlLang = null;
            elemTop = 0;

            attrStack = new AttrName[AttributeArrayInitialSize];

            attrValue = new StringBuilder();

            hasher = new SecureStringHasher();
        }
开发者ID:gbarnett,项目名称:shared-source-cli-2.0,代码行数:47,代码来源:xmlwellformedwriter.cs

示例14: StringToQName

 protected static XmlQualifiedName StringToQName(string value, IXmlNamespaceResolver nsResolver)
 {
     string str;
     string str2;
     value = value.Trim();
     try
     {
         ValidateNames.ParseQNameThrow(value, out str, out str2);
     }
     catch (XmlException exception)
     {
         throw new FormatException(exception.Message);
     }
     if (nsResolver == null)
     {
         throw new InvalidCastException(Res.GetString("XmlConvert_TypeNoNamespace", new object[] { value, str }));
     }
     string ns = nsResolver.LookupNamespace(str);
     if (ns == null)
     {
         throw new InvalidCastException(Res.GetString("XmlConvert_TypeNoNamespace", new object[] { value, str }));
     }
     return new XmlQualifiedName(str2, ns);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:24,代码来源:XmlBaseConverter.cs

示例15: SelectInternal

        private IEnumerable<XObject> SelectInternal(string path, IXmlNamespaceResolver manager)
        {
            if (path.StartsWith("/"))
            {
                path = path.Substring(1);
            }

            var nodes = (IEnumerable<XObject>) new[] {_obj};
            foreach (var part in path.Split('/'))
            {
                if (part == "*")
                {
                    nodes = nodes.Cast<XContainer>().Elements();
                }
                else if (part == "")
                {
                    nodes = nodes.Cast<XContainer>().Descendants();
                }
                else
                {
                    var isAttribute = part.StartsWith("@");
                    var str = isAttribute ? part.Substring(1) : part;
                    var pos = str.IndexOf(":", StringComparison.Ordinal);
                    var name = pos >= 0
                                   ? XName.Get(str.Substring(pos + 1), manager.LookupNamespace(str.Substring(0, pos)))
                                   : XName.Get(str);
                    if (isAttribute)
                    {
                        nodes = nodes.Cast<XElement>().Attributes(name);
                    }
                    else
                    {
                        nodes = nodes.Cast<XContainer>().Elements(name);
                    }
                }
            }
            return nodes;
        }
开发者ID:nicocrm,项目名称:DotNetSDataClient,代码行数:38,代码来源:Stub.cs


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