コード例 #1
0
        public XPathMutableCursor(IXmlNode parent, CompiledXPath path,
                                  IXmlIncludedTypeMap knownTypes, IXmlNamespaceSource namespaces, CursorFlags flags)
            : base(path, namespaces, parent)
        {
            if (null == parent)
            {
                throw Error.ArgumentNull("parent");
            }
            if (null == path)
            {
                throw Error.ArgumentNull("path");
            }
            if (null == knownTypes)
            {
                throw Error.ArgumentNull("knownTypes");
            }
            if (!path.IsCreatable)
            {
                throw Error.XPathNotCreatable(path);
            }

            this.step       = path.FirstStep;
            this.knownTypes = knownTypes;
            this.flags      = flags;

            var source = parent.RequireRealizable <XPathNavigator>();

            if (source.IsReal)
            {
                iterator = new XPathBufferedNodeIterator(
                    source.Value.Select(path.FirstStep.Path));
            }
        }
コード例 #2
0
        public XPathReadOnlyCursor(
            IXmlNode parent,
            CompiledXPath path,
            IXmlIncludedTypeMap includedTypes,
            IXmlNamespaceSource namespaces,
            CursorFlags flags
            ) : base(path, namespaces, parent)
        {
            if (parent == null)
            {
                throw Error.ArgumentNull(nameof(parent));
            }
            if (path == null)
            {
                throw Error.ArgumentNull(nameof(path));
            }
            if (includedTypes == null)
            {
                throw Error.ArgumentNull(nameof(includedTypes));
            }

            this.includedTypes = includedTypes;
            this.flags         = flags;

            Reset();
        }
コード例 #3
0
        private static bool ParseStep(Tokenizer source, CompiledXPath path, ref CompiledXPathStep step)
        {
            var previous = step;
            var start    = source.Index;

            if (!ParseNodeCore(source, StepFactory, ref step))
            {
                return(false);
            }

            if (step != previous)
            {
                var text = source.GetConsumedText(start);
                step.Path = XPathExpression.Compile(text);

                if (previous == null)
                {
                    path.FirstStep = step;
                }
                else
                {
                    LinkNodes(previous, step);
                }

                path.Depth++;
            }
            return(true);
        }
コード例 #4
0
		public XPathAttribute(string path)
		{
			if (path == null)
				throw Error.ArgumentNull("path");

			this.getPath = XPathCompiler.Compile(path);
			this.setPath = this.getPath;
		}
コード例 #5
0
        internal static Exception XPathNotCreatable(CompiledXPath path)
        {
            var message = string.Format(
                "The path '{0}' is not a creatable XPath expression.",
                path.Path.Expression);

            return(new XPathException(message));
        }
コード例 #6
0
ファイル: XmlSelfCursor.cs プロジェクト: belav/Core
 public IXmlCursor Select(
     CompiledXPath path,
     IXmlIncludedTypeMap knownTypes,
     IXmlNamespaceSource namespaces,
     CursorFlags flags
     )
 {
     return(node.Select(path, knownTypes, namespaces, flags));
 }
コード例 #7
0
		public XPathAttribute(string get, string set)
		{
			if (get == null)
				throw Error.ArgumentNull("get");
			if (set == null)
				throw Error.ArgumentNull("set");

			this.getPath = XPathCompiler.Compile(get);
			this.setPath = XPathCompiler.Compile(set);
		}
コード例 #8
0
        public XPathAttribute(string path)
        {
            if (path == null)
            {
                throw Error.ArgumentNull("path");
            }

            this.getPath = XPathCompiler.Compile(path);
            this.setPath = this.getPath;
        }
コード例 #9
0
ファイル: SysXmlNode.cs プロジェクト: belav/Core
 public IXmlCursor Select(
     CompiledXPath path,
     IXmlIncludedTypeMap includedTypes,
     IXmlNamespaceSource namespaces,
     CursorFlags flags
     )
 {
     return(flags.SupportsMutation()
       ? (IXmlCursor) new XPathMutableCursor(this, path, includedTypes, namespaces, flags)
       : (IXmlCursor) new XPathReadOnlyCursor(this, path, includedTypes, namespaces, flags));
 }
コード例 #10
0
        public XPathAttribute(string get, string set)
        {
            if (get == null)
            {
                throw Error.ArgumentNull("get");
            }
            if (set == null)
            {
                throw Error.ArgumentNull("set");
            }

            this.getPath = XPathCompiler.Compile(get);
            this.setPath = XPathCompiler.Compile(set);
        }
コード例 #11
0
		public XPathReadOnlyCursor(IXmlNode parent, CompiledXPath path,
			IXmlIncludedTypeMap includedTypes, IXmlNamespaceSource namespaces, CursorFlags flags)
			: base(path, namespaces, parent)
		{
			if (parent == null)
				throw Error.ArgumentNull("parent");
			if (path == null)
				throw Error.ArgumentNull("path");
			if (includedTypes == null)
				throw Error.ArgumentNull("includedTypes");

			this.includedTypes = includedTypes;
			this.flags         = flags;

			Reset();
		}
コード例 #12
0
        public void Configure(XPathAttribute attribute)
        {
            if (path != null)
            {
                throw Error.AttributeConflict(path.Path.Expression);
            }

            path = attribute.SetPath;

            if (path == attribute.GetPath)
            {
                return;
            }
            else if (Serializer.CanGetStub)
            {
                throw Error.SeparateGetterSetterOnComplexType(path.Path.Expression);
            }

            defaultAccessor = new DefaultAccessor(this, attribute.GetPath);
        }
コード例 #13
0
ファイル: XPathMutableCursor.cs プロジェクト: elevine/Core
		public XPathMutableCursor(IXmlNode parent, CompiledXPath path,
			IXmlIncludedTypeMap knownTypes, IXmlNamespaceSource namespaces, CursorFlags flags)
			: base(path, namespaces, parent)
		{
			if (null == parent)
				throw Error.ArgumentNull("parent");
			if (null == path)
				throw Error.ArgumentNull("path");
			if (null == knownTypes)
				throw Error.ArgumentNull("knownTypes");
			if (!path.IsCreatable)
				throw Error.XPathNotCreatable(path);

			this.step       = path.FirstStep;
			this.knownTypes = knownTypes;
			this.flags      = flags;

			var source = parent.RequireRealizable<XPathNavigator>();
			if (source.IsReal)
				iterator = new XPathBufferedNodeIterator(
					source.Value.Select(path.FirstStep.Path));
		}
コード例 #14
0
 private static bool ParsePath(Tokenizer source, CompiledXPath path)
 {
     for (CompiledXPathStep step = null;;)
     {
         if (!ParseStep(source, path, ref step))
         {
             return(false);
         }
         if (source.Token == Token.EndOfInput)
         {
             return(true);
         }
         if (!Consume(source, Token.StepSeparator))
         {
             return(false);
         }
         if (step.IsAttribute)
         {
             return(false);
         }
     }
 }
コード例 #15
0
        public static CompiledXPath Compile(string path)
        {
            if (null == path)
            {
                throw Error.ArgumentNull("path");
            }

            // Compile whole path to catch errors
            var result = new CompiledXPath();

            result.Path = XPathExpression.Compile(path);

            // Try to split into individual path steps
            var tokenizer = new Tokenizer(path);

            if (!ParsePath(tokenizer, result))
            {
                result.MakeNotCreatable();
            }

            // Finish compilation
            result.Prepare();
            return(result);
        }
コード例 #16
0
			public void Enlist(CompiledXPath path)
			{
				throw Error.NotSupported();
			}
コード例 #17
0
ファイル: XPathNode.cs プロジェクト: JustF2A/Castle
 protected XPathNode(CompiledXPath path, IXmlNamespaceSource namespaces, IXmlNode parent)
     : base(namespaces, parent)
 {
     this.xpath = path;
 }
コード例 #18
0
ファイル: XPathNode.cs プロジェクト: JustF2A/Castle
 public virtual object Evaluate(CompiledXPath path)
 {
     return(node.Evaluate(path.Path));
 }
コード例 #19
0
 public void Enlist(CompiledXPath path)
 {
     path.SetContext(XPathContext);
 }
コード例 #20
0
		protected abstract IXmlCursor Cursor(IXmlNode parent, CompiledXPath path, IXmlIncludedTypeMap includedTypes, CursorFlags flags);
コード例 #21
0
ファイル: XPathMutableCursor.cs プロジェクト: belav/Core
 public override object Evaluate(CompiledXPath path)
 {
     return(HasCurrent ? base.Evaluate(path) : null);
 }
コード例 #22
0
 public object Evaluate(CompiledXPath path)
 {
     return(node.Evaluate(path));
 }
コード例 #23
0
 public void Enlist(CompiledXPath path)
 {
     throw Error.NotSupported();
 }
コード例 #24
0
ファイル: SysXmlNode.cs プロジェクト: hzhhhbb/Core
 public virtual object Evaluate(CompiledXPath path)
 {
     return(node.CreateNavigator().Evaluate(path.Path));
 }
コード例 #25
0
ファイル: SysXmlCursor.cs プロジェクト: elevine/Core
		public override object Evaluate(CompiledXPath path)
		{
			return HasCurrent ? base.Evaluate(path) : null;
		}
コード例 #26
0
		public void Enlist(CompiledXPath path)
		{
			path.SetContext(XPathContext);
		}
コード例 #27
0
 public DefaultAccessor(XPathBehaviorAccessor parent, CompiledXPath path)
     : base(parent.ClrType, parent.Context)
 {
     this.parent = parent;
     this.path   = path;
 }
コード例 #28
0
ファイル: XmlMetadata.cs プロジェクト: JustF2A/Castle
        public XmlMetadata(DictionaryAdapterMeta meta, IEnumerable <string> reservedNamespaceUris)
        {
            if (meta == null)
            {
                throw Error.ArgumentNull("meta");
            }
            if (reservedNamespaceUris == null)
            {
                throw Error.ArgumentNull("reservedNamespaceUris");
            }

            source        = meta;
            clrType       = meta.Type;
            context       = new XmlContext(this);
            includedTypes = new XmlIncludedTypeSet();

            this.reservedNamespaceUris
                = reservedNamespaceUris as HashSet <string>
                  ?? new HashSet <string>(reservedNamespaceUris);

            var xmlRoot       = null as XmlRootAttribute;
            var xmlType       = null as XmlTypeAttribute;
            var xmlDefaults   = null as XmlDefaultsAttribute;
            var xmlInclude    = null as XmlIncludeAttribute;
            var xmlNamespace  = null as XmlNamespaceAttribute;
            var reference     = null as ReferenceAttribute;
            var xPath         = null as XPathAttribute;
            var xPathVariable = null as XPathVariableAttribute;
            var xPathFunction = null as XPathFunctionAttribute;

            foreach (var behavior in meta.Behaviors)
            {
                if (TryCast(behavior, ref xmlRoot))
                {
                }
                else if (TryCast(behavior, ref xmlType))
                {
                }
                else if (TryCast(behavior, ref xmlDefaults))
                {
                }
                else if (TryCast(behavior, ref xmlInclude))
                {
                    AddPendingInclude(xmlInclude);
                }
                else if (TryCast(behavior, ref xmlNamespace))
                {
                    context.AddNamespace(xmlNamespace);
                }
                else if (TryCast(behavior, ref reference))
                {
                }
                else if (TryCast(behavior, ref xPath))
                {
                }
                else if (TryCast(behavior, ref xPathVariable))
                {
                    context.AddVariable(xPathVariable);
                }
                else if (TryCast(behavior, ref xPathFunction))
                {
                    context.AddFunction(xPathFunction);
                }
            }

            if (xmlDefaults != null)
            {
                qualified  = xmlDefaults.Qualified;
                isNullable = xmlDefaults.IsNullable;
            }

            if (reference != null)
            {
                isReference = true;
            }

            typeLocalName = XmlConvert.EncodeLocalName
                            (
                (!meta.HasXmlType() ? null : meta.GetXmlType().NonEmpty()) ??
                (xmlType == null    ? null : xmlType.TypeName.NonEmpty()) ??
                GetDefaultTypeLocalName(clrType)
                            );

            rootLocalName = XmlConvert.EncodeLocalName
                            (
                (xmlRoot == null ? null : xmlRoot.ElementName.NonEmpty()) ??
                typeLocalName
                            );

            typeNamespaceUri =
                (
                    (xmlType == null ? null : xmlType.Namespace)
                );

            rootNamespaceUri =
                (
                    (xmlRoot == null ? null : xmlRoot.Namespace)
                );

            childNamespaceUri =
                (
                    typeNamespaceUri ??
                    rootNamespaceUri
                );

            if (xPath != null)
            {
                path = xPath.GetPath;
                path.SetContext(context);
            }
        }
コード例 #29
0
		protected override IXmlCursor Cursor(IXmlNode parent, CompiledXPath path, IXmlIncludedTypeMap includedTypes, CursorFlags flags)
		{
			return new XPathMutableCursor(parent, path, includedTypes, NamespaceSource.Instance, flags);
		}