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


C# IXmlNamespaceResolver类代码示例

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


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

示例1: Select

 public static IEnumerable Select(object container, string xPath, IXmlNamespaceResolver resolver)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     if (string.IsNullOrEmpty(xPath))
     {
         throw new ArgumentNullException("xPath");
     }
     ArrayList list = new ArrayList();
     IXPathNavigable navigable = container as IXPathNavigable;
     if (navigable == null)
     {
         throw new ArgumentException(System.Web.SR.GetString("XPathBinder_MustBeIXPathNavigable", new object[] { container.GetType().FullName }));
     }
     XPathNodeIterator iterator = navigable.CreateNavigator().Select(xPath, resolver);
     while (iterator.MoveNext())
     {
         IHasXmlNode current = iterator.Current as IHasXmlNode;
         if (current == null)
         {
             throw new InvalidOperationException(System.Web.SR.GetString("XPathBinder_MustHaveXmlNodes"));
         }
         list.Add(current.GetNode());
     }
     return list;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:XPathBinder.cs

示例2: Eval

 public static object Eval(object container, string xPath, IXmlNamespaceResolver resolver)
 {
     if (container == null)
     {
         throw new ArgumentNullException("container");
     }
     if (string.IsNullOrEmpty(xPath))
     {
         throw new ArgumentNullException("xPath");
     }
     IXPathNavigable navigable = container as IXPathNavigable;
     if (navigable == null)
     {
         throw new ArgumentException(System.Web.SR.GetString("XPathBinder_MustBeIXPathNavigable", new object[] { container.GetType().FullName }));
     }
     object obj2 = navigable.CreateNavigator().Evaluate(xPath, resolver);
     XPathNodeIterator iterator = obj2 as XPathNodeIterator;
     if (iterator == null)
     {
         return obj2;
     }
     if (iterator.MoveNext())
     {
         return iterator.Current.Value;
     }
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:XPathBinder.cs

示例3: TryParseValue

 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     if ((s == null) || (s.Length == 0))
     {
         return new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
     }
     Exception exception = DatatypeImplementation.durationFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         XsdDuration duration;
         exception = XsdDuration.TryParse(s, XsdDuration.DurationType.YearMonthDuration, out duration);
         if (exception == null)
         {
             TimeSpan span;
             exception = duration.TryToTimeSpan(XsdDuration.DurationType.YearMonthDuration, out span);
             if (exception == null)
             {
                 exception = DatatypeImplementation.durationFacetsChecker.CheckValueFacets(span, this);
                 if (exception == null)
                 {
                     typedValue = span;
                     return null;
                 }
             }
         }
     }
     return exception;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:29,代码来源:Datatype_yearMonthDuration.cs

示例4: ChangeType

 public override object ChangeType(string value, Type destinationType, IXmlNamespaceResolver nsResolver)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     if (destinationType == XmlBaseConverter.ObjectType)
     {
         destinationType = base.DefaultClrType;
     }
     if (destinationType == XmlBaseConverter.StringType)
     {
         return value;
     }
     if (destinationType == XmlBaseConverter.XmlAtomicValueType)
     {
         return new XmlAtomicValue(base.SchemaType, value);
     }
     if (destinationType == XmlBaseConverter.XPathItemType)
     {
         return new XmlAtomicValue(base.SchemaType, value);
     }
     return this.ChangeListType(value, destinationType, nsResolver);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:XmlStringConverter.cs

示例5: ParseConfiguration

		protected override void ParseConfiguration(XPathNavigator configurationElement, IXmlNamespaceResolver xmlNamespaceResolver, ContentType contentType)
		{
            //<MinValue>-6</MinValue>
			//<MaxValue>42</MaxValue>
			foreach (XPathNavigator node in configurationElement.SelectChildren(XPathNodeType.Element))
			{
				switch (node.LocalName)
				{
					case MinValueName:
                        int minValue;
                        if (Int32.TryParse(node.InnerXml, out minValue))
                            _minValue = minValue;
						break;
					case MaxValueName:
						int maxValue;
						if (Int32.TryParse(node.InnerXml, out maxValue))
							_maxValue = maxValue;
						break;
                    case ShowAsPercentageName:
                        bool perc;
                        if (Boolean.TryParse(node.InnerXml, out perc))
                            _showAsPercentage = perc;
                        break;
				}
			}
		}
开发者ID:jhuntsman,项目名称:FlexNet,代码行数:26,代码来源:IntegerFieldSetting.cs

示例6: TryParseValue

 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     if ((s == null) || (s.Length == 0))
     {
         return new XmlSchemaException("Sch_EmptyAttributeValue", string.Empty);
     }
     Exception exception = DatatypeImplementation.qnameFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         XmlQualifiedName name = null;
         try
         {
             string str;
             name = XmlQualifiedName.Parse(s, nsmgr, out str);
         }
         catch (ArgumentException exception2)
         {
             return exception2;
         }
         catch (XmlException exception3)
         {
             return exception3;
         }
         exception = DatatypeImplementation.qnameFacetsChecker.CheckValueFacets(name, this);
         if (exception == null)
         {
             typedValue = name;
             return null;
         }
     }
     return exception;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:Datatype_NOTATION.cs

示例7: Apply

        public void Apply (XmlDocument targetDocument, IXmlNamespaceResolver context) {

            XPathExpression local_file_expression = file_expression.Clone();
            local_file_expression.SetContext(context);

            XPathExpression local_source_expression = source_expression.Clone();
            local_source_expression.SetContext(context);

            XPathExpression local_target_expression = target_expression.Clone();
            local_target_expression.SetContext(context);

            string file_name = (string) targetDocument.CreateNavigator().Evaluate(local_file_expression);
            string file_path = Path.Combine(root_directory, file_name);

            if (!File.Exists(file_path)) return;
            XPathDocument sourceDocument = new XPathDocument(file_path);

            XPathNavigator target_node = targetDocument.CreateNavigator().SelectSingleNode(local_target_expression);
            if (target_node == null) return;

            XPathNodeIterator source_nodes = sourceDocument.CreateNavigator().Select(local_source_expression);
            foreach (XPathNavigator source_node in source_nodes) {
                target_node.AppendChild(source_node);
            }
       
        }
开发者ID:Balamir,项目名称:DotNetOpenAuth,代码行数:26,代码来源:CopyFromFiles.cs

示例8: ChangeType

 public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     Type derivedType = value.GetType();
     if (destinationType == XmlBaseConverter.ObjectType)
     {
         destinationType = base.DefaultClrType;
     }
     if ((destinationType == XmlBaseConverter.XPathNavigatorType) && XmlBaseConverter.IsDerivedFrom(derivedType, XmlBaseConverter.XPathNavigatorType))
     {
         return (XPathNavigator) value;
     }
     if ((destinationType == XmlBaseConverter.XPathItemType) && XmlBaseConverter.IsDerivedFrom(derivedType, XmlBaseConverter.XPathNavigatorType))
     {
         return (XPathItem) value;
     }
     return this.ChangeListType(value, destinationType, nsResolver);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:25,代码来源:XmlNodeConverter.cs

示例9: Eval

        public static object Eval(object container, string xPath, IXmlNamespaceResolver resolver) {
            if (container == null) {
                throw new ArgumentNullException("container");
            }
            if (String.IsNullOrEmpty(xPath)) {
                throw new ArgumentNullException("xPath");
            }

            IXPathNavigable node = container as IXPathNavigable;
            if (node == null) {
                throw new ArgumentException(SR.GetString(SR.XPathBinder_MustBeIXPathNavigable, container.GetType().FullName));
            }
            XPathNavigator navigator = node.CreateNavigator();

            object retValue = navigator.Evaluate(xPath, resolver);

            // If we get back an XPathNodeIterator instead of a simple object, advance
            // the iterator to the first node and return the value.
            XPathNodeIterator iterator = retValue as XPathNodeIterator;
            if (iterator != null) {
                if (iterator.MoveNext()) {
                    retValue = iterator.Current.Value;
                }
                else {
                    retValue = null;
                }
            }

            return retValue;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:30,代码来源:XPathBinder.cs

示例10: ReadContentAsAsync

        // Concatenates values of textual nodes of the current content, ignoring comments and PIs, expanding entity references, 
        // and converts the content to the requested type. Stops at start tags and end tags.
        public virtual async Task<object> ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver)
        {
            if (!CanReadContentAs())
            {
                throw CreateReadContentAsException("ReadContentAs");
            }

            string strContentValue = await InternalReadContentAsStringAsync().ConfigureAwait(false);
            if (returnType == typeof(string))
            {
                return strContentValue;
            }
            else
            {
                try
                {
                    return XmlUntypedStringConverter.Instance.FromString(strContentValue, returnType, (namespaceResolver == null ? this as IXmlNamespaceResolver : namespaceResolver));
                }
                catch (FormatException e)
                {
                    throw new XmlException(SR.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
                }
                catch (InvalidCastException e)
                {
                    throw new XmlException(SR.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
                }
            }
        }
开发者ID:Rayislandstyle,项目名称:corefx,代码行数:30,代码来源:XmlReaderAsync.cs

示例11: ReadContentAsAsync

        public override async Task< object > ReadContentAsAsync(Type returnType, IXmlNamespaceResolver namespaceResolver) {
            if (!CanReadContentAs(this.NodeType)) {
                throw CreateReadContentAsException("ReadContentAs");
            }
            string originalStringValue;

            var tuple_0 = await InternalReadContentAsObjectTupleAsync(false).ConfigureAwait(false);
            originalStringValue = tuple_0.Item1;

            object typedValue = tuple_0.Item2;

            XmlSchemaType xmlType = NodeType == XmlNodeType.Attribute ? AttributeXmlType : ElementXmlType; //
            try {
                if (xmlType != null) {
                    // special-case convertions to DateTimeOffset; typedValue is by default a DateTime 
                    // which cannot preserve time zone, so we need to convert from the original string
                    if (returnType == typeof(DateTimeOffset) && xmlType.Datatype is Datatype_dateTimeBase) {
                        typedValue = originalStringValue;
                    }
                    return xmlType.ValueConverter.ChangeType(typedValue, returnType);
                }
                else {
                    return XmlUntypedConverter.Untyped.ChangeType(typedValue, returnType, namespaceResolver);
                }
            }
            catch (FormatException e) {
                throw new XmlException(Res.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
            }
            catch (InvalidCastException e) {
                throw new XmlException(Res.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
            }
            catch (OverflowException e) {
                throw new XmlException(Res.Xml_ReadContentAsFormatException, returnType.ToString(), e, this as IXmlLineInfo);
            }
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:35,代码来源:XsdValidatingReaderAsync.cs

示例12: TryParseValue

 internal override Exception TryParseValue(string s, XmlNameTable nameTable, IXmlNamespaceResolver nsmgr, out object typedValue)
 {
     typedValue = null;
     Exception exception = DatatypeImplementation.binaryFacetsChecker.CheckLexicalFacets(ref s, this);
     if (exception == null)
     {
         byte[] buffer = null;
         try
         {
             buffer = XmlConvert.FromBinHexString(s, false);
         }
         catch (ArgumentException exception2)
         {
             return exception2;
         }
         catch (XmlException exception3)
         {
             return exception3;
         }
         exception = DatatypeImplementation.binaryFacetsChecker.CheckValueFacets(buffer, this);
         if (exception == null)
         {
             typedValue = buffer;
             return null;
         }
     }
     return exception;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:28,代码来源:Datatype_hexBinary.cs

示例13: ChangeType

 public override object ChangeType(object value, Type destinationType, IXmlNamespaceResolver nsResolver)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     if (destinationType == null)
     {
         throw new ArgumentNullException("destinationType");
     }
     Type sourceType = value.GetType();
     if ((sourceType == XmlBaseConverter.XmlAtomicValueType) && this.hasAtomicMember)
     {
         return ((XmlAtomicValue) value).ValueAs(destinationType, nsResolver);
     }
     if ((sourceType == XmlBaseConverter.XmlAtomicValueArrayType) && this.hasListMember)
     {
         return XmlAnyListConverter.ItemList.ChangeType(value, destinationType, nsResolver);
     }
     if (!(sourceType == XmlBaseConverter.StringType))
     {
         throw base.CreateInvalidClrMappingException(sourceType, destinationType);
     }
     if (destinationType == XmlBaseConverter.StringType)
     {
         return value;
     }
     XsdSimpleValue value2 = (XsdSimpleValue) base.SchemaType.Datatype.ParseValue((string) value, new NameTable(), nsResolver, true);
     return value2.XmlType.ValueConverter.ChangeType((string) value, destinationType, nsResolver);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:30,代码来源:XmlUnionConverter.cs

示例14: XPathEvaluate

		public static object XPathEvaluate (this XNode node, string expression, IXmlNamespaceResolver resolver)
		{
			object navigationResult = CreateNavigator (node).Evaluate (expression, resolver);
			if (!(navigationResult is XPathNodeIterator))
				return navigationResult;
			return GetUnderlyingXObjects((XPathNodeIterator) navigationResult);
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:Extensions.cs

示例15: XPathSelectElement

		public static XElement XPathSelectElement (this XNode node, string expression, IXmlNamespaceResolver resolver)
		{
			XPathNavigator nav = CreateNavigator (node).SelectSingleNode (expression, resolver);
			if (nav == null)
				return null;
			return nav.UnderlyingObject as XElement;
		}
开发者ID:carrie901,项目名称:mono,代码行数:7,代码来源:Extensions.cs


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