Inheritance: System.Xml.Xsl.XsltContext
 public XPathContext(XPathContext parent)
     : base((NameTable)parent.NameTable)
 {
     this.parent = parent;
     Arguments   = new XsltArgumentList();
     functions   = new Dictionary <string, Func <IXsltContextFunction> >();
 }
Exemple #2
0
		public XPathContext(XPathContext parent) 
			: base((NameTable)parent.NameTable)
		{
			this.parent = parent;
			Arguments = new XsltArgumentList();
			functions = new Dictionary<string, Func<IXsltContextFunction>>();
		}
Exemple #3
0
 public XPathResult(PropertyDescriptor property, object result, XPathContext context, object matchingBehavior, Func <XPathNavigator> create)
 {
     Result                = result;
     Property              = property;
     Type                  = (property != null) ? Property.PropertyType : null;
     Context               = context;
     this.create           = create;
     this.matchingBehavior = matchingBehavior;
     CanWrite              = (create != null || result is XPathNavigator);
 }
Exemple #4
0
		protected XPathAdapter(XPathNavigator source, XPathAdapter parent)
		{
			Parent = parent;
			Context = parent.Context.CreateChild(null);
			root = source.Clone();
		}
Exemple #5
0
		protected XPathAdapter(Func<XPathNavigator> createSource, XPathAdapter parent)
		{
			Parent = parent;
			Context = parent.Context.CreateChild(null);
			createRoot = createSource;
		}
Exemple #6
0
		public XPathContext(XPathContext parent) : this((NameTable)parent.NameTable)
		{
			this.parent = parent;
		}
Exemple #7
0
		public XPathAdapter(IXPathNavigable source)
		{
			Source = source;
			Context = new XPathContext();
			root = source.CreateNavigator();
		}
Exemple #8
0
 public XPathResult(PropertyDescriptor property, object result,
                    XPathContext context, object matchingBehavior)
     : this(property, result, context, matchingBehavior, null)
 {
 }
Exemple #9
0
 public XPathResult(Type type, object result, XPathContext context, object matchingBehavior)
     : this(null, result, context, matchingBehavior, null)
 {
     Type = type;
 }
Exemple #10
0
		protected XPathAdapter(XPathNavigator source, XPathAdapter parent)
		{
			this.parent = parent;
			context = parent.context.CreateChild();
			root = source.Clone();
		}
Exemple #11
0
 public XPathContext(XPathContext parent)
     : base((NameTable)parent.NameTable)
 {
     this.parent = parent;
     Arguments   = new XsltArgumentList();
 }
Exemple #12
0
 protected XPathAdapter(Func <XPathNavigator> createSource, XPathAdapter parent)
 {
     Parent     = parent;
     Context    = parent.Context.CreateChild(null);
     createRoot = createSource;
 }
Exemple #13
0
		void IDictionaryInitializer.Initialize(IDictionaryAdapter dictionaryAdapter, object[] behaviors)
		{
			var meta = dictionaryAdapter.Meta;
			if (meta.MetaInitializers.OfType<XPathBehavior>().FirstOrDefault() == null)
			{
				throw new InvalidOperationException(string.Format(
					"Interface {0} requested xpath support, but was not configured properly.  " +
					"Did you forget to add an XPathBehavior?", meta.Type.FullName));
			}

			var xmlMeta = dictionaryAdapter.GetXmlMeta();

			if (dictionaryAdapter.This.CreateStrategy == null)
			{
				dictionaryAdapter.This.CreateStrategy = this;
				dictionaryAdapter.This.AddCopyStrategy(this);
			}

			if (rootXmlMeta == null)
			{
				rootXmlMeta = xmlMeta;
				Context.ApplyBehaviors(rootXmlMeta, behaviors);

				if (Parent == null)
				{
					foreach (var behavior in behaviors)
					{
						if (behavior is XPathAttribute)
						{
							var attrib = (XPathAttribute)behavior;
							var compiledExpression = attrib.CompiledExpression;
							if (MoveOffRoot(root, XPathNodeType.Element) == false || Context.Matches(compiledExpression, root))
							{
								break;
							}

							var navigator = Context.SelectSingleNode(compiledExpression, root);
							if (navigator != null)
							{
								root = navigator;
								break;
							}
						}
					}
					MoveOffRoot(root, XPathNodeType.Element);
				}
			}
			else
			{
				if (overlays == null)
					overlays = new Dictionary<Type, XPathContext>();

				XPathContext overlay;
				if (overlays.TryGetValue(meta.Type, out overlay) == false)
				{
					overlay = new XPathContext().ApplyBehaviors(xmlMeta, behaviors);
					overlays.Add(meta.Type, overlay);
				}
			}
		}
Exemple #14
0
 protected XPathAdapter(XPathNavigator source, XPathAdapter parent)
 {
     Parent  = parent;
     Context = parent.Context.CreateChild(null);
     root    = source.Clone();
 }
Exemple #15
0
 public XPathAdapter(IXPathNavigable source)
 {
     Source  = source;
     Context = new XPathContext();
     root    = source.CreateNavigator();
 }
Exemple #16
0
		public XPathContext(XPathContext parent) 
			: base((NameTable)parent.NameTable)
		{
			this.parent = parent;
			Arguments = new XsltArgumentList();
		}
Exemple #17
0
			public XPathSemantics(XPathContext xpathContext)
			{
				this.xpathContext = xpathContext;
			}
Exemple #18
0
		protected XPathAdapter(Func<XPathNavigator> createSource, XPathAdapter parent)
		{
			this.parent = parent;
			context = parent.context.CreateChild();
			createRoot = createSource;
		}
Exemple #19
0
 public XPathSemantics(XPathContext xpathContext)
 {
     this.xpathContext = xpathContext;
 }
Exemple #20
0
        void IDictionaryInitializer.Initialize(IDictionaryAdapter dictionaryAdapter, object[] behaviors)
        {
            var meta = dictionaryAdapter.Meta;

            if (meta.MetaInitializers.OfType <XPathBehavior>().FirstOrDefault() == null)
            {
                throw new InvalidOperationException(string.Format(
                                                        "Interface {0} requested xpath support, but was not configured properly.  " +
                                                        "Did you forget to add an XPathBehavior?", meta.Type.FullName));
            }

            var xmlMeta = dictionaryAdapter.GetXmlMeta();

            if (dictionaryAdapter.This.CreateStrategy == null)
            {
                dictionaryAdapter.This.CreateStrategy = this;
                dictionaryAdapter.This.AddCopyStrategy(this);
            }

            if (rootXmlMeta == null)
            {
                rootXmlMeta = xmlMeta;
                Context.ApplyBehaviors(rootXmlMeta, behaviors);

                if (Parent == null)
                {
                    foreach (var behavior in behaviors)
                    {
                        if (behavior is XPathAttribute)
                        {
                            var attrib             = (XPathAttribute)behavior;
                            var compiledExpression = attrib.CompiledExpression;
                            if (MoveOffRoot(root, XPathNodeType.Element) == false || Context.Matches(compiledExpression, root))
                            {
                                break;
                            }

                            var navigator = Context.SelectSingleNode(compiledExpression, root);
                            if (navigator != null)
                            {
                                root = navigator;
                                break;
                            }
                        }
                    }
                    MoveOffRoot(root, XPathNodeType.Element);
                }
            }
            else
            {
                if (overlays == null)
                {
                    overlays = new Dictionary <Type, XPathContext>();
                }

                XPathContext overlay;
                if (overlays.TryGetValue(meta.Type, out overlay) == false)
                {
                    overlay = new XPathContext().ApplyBehaviors(xmlMeta, behaviors);
                    overlays.Add(meta.Type, overlay);
                }
            }
        }