Evaluate() public method

public Evaluate ( XPathExpression expr ) : object
expr XPathExpression
return object
Ejemplo n.º 1
0
        public override void WriteSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            writer.WriteStartBlock(Language);

            // Check the list of assemblies for which to generate XAML syntax
            string assemblyName = (string)reflection.Evaluate(apiContainingAssemblyExpression);
            string namespaceName = (string)reflection.Evaluate(apiContainingNamespaceNameExpression);
            if (!xamlAssemblies.ContainsKey(assemblyName.ToLower()))
            {
                WriteXamlBoilerplate(XamlBoilerplateID.nonXamlAssemblyBoilerplate, writer);
            }
            else
            {
                string group = (string)reflection.Evaluate(apiGroupExpression);
                switch (group)
                {
                    case "namespace":
                        WriteNamespaceSyntax(reflection, writer);
                        break;
                    case "type":
                        WriteTypeSyntax(reflection, writer);
                        break;
                    case "member":
                        WriteMemberSyntax(reflection, writer);
                        break;
                }
                WriteXamlXmlnsUri(assemblyName, namespaceName, writer);
            }

            writer.WriteEndBlock();
        }
        // class: done
		public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = reflection.Evaluate(apiNameExpression).ToString();
			bool isAbstract = (bool) reflection.Evaluate(apiIsAbstractTypeExpression);
			bool isSealed = (bool) reflection.Evaluate(apiIsSealedTypeExpression);
			bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			if (isAbstract) {
				if (isSealed) {
					writer.WriteKeyword("static");
				} else {
					writer.WriteKeyword("abstract");
				}
				writer.WriteString(" ");
			} else {
				if (isSealed) {
					writer.WriteKeyword("sealed");
					writer.WriteString(" ");
				}
			}
			writer.WriteKeyword("class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteBaseClassAndImplementedInterfaces(reflection, writer);
			WriteGenericTemplateConstraints(reflection, writer);

		}
        public override void WriteDelegateSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);

            if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);

            WriteAttributes(reflection, writer);

            writer.WriteKeyword("type");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
            writer.WriteString(" = ");
            writer.WriteLine();
            writer.WriteString("    ");
            writer.WriteKeyword("delegate");
            writer.WriteString(" ");
            writer.WriteKeyword("of");
            writer.WriteString(" ");

            WriteParameters(reflection, writer);

            writer.WriteKeyword("->");
            writer.WriteString(" ");
            WriteReturnValue(reflection, writer);

        }
		public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			if (IsUnsupportedGeneric(reflection, writer)) return;

			string name = reflection.Evaluate(apiNameExpression).ToString();
			bool isAbstract = (bool) reflection.Evaluate(apiIsAbstractTypeExpression);
			bool isSealed = (bool) reflection.Evaluate(apiIsSealedTypeExpression);
			bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			if (isSealed) {
				writer.WriteKeyword("final");
				writer.WriteString(" ");
			} else if (isAbstract) {
				writer.WriteKeyword("abstract");
				writer.WriteString(" ");
			}
			writer.WriteKeyword("class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);

			XPathNavigator baseClass = reflection.SelectSingleNode(apiBaseClassExpression);
			if ((baseClass != null) && !((bool) baseClass.Evaluate(typeIsObjectExpression))) {
				writer.WriteString(" ");
				writer.WriteKeyword("extends");
				writer.WriteString(" ");
				WriteTypeReference(baseClass, writer);
			}

			WriteImplementedInterfaces(reflection, writer);

		}
Ejemplo n.º 5
0
        /// <inheritdoc />
        public override void WriteClassSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {
            if(IsUnsupportedGeneric(reflection, writer))
                return;

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isAbstract = (bool)reflection.Evaluate(apiIsAbstractTypeExpression);
            bool isSealed = (bool)reflection.Evaluate(apiIsSealedTypeExpression);

            WriteAccessModifier(reflection, writer);

            if(isSealed)
            {
                writer.WriteKeyword("final");
                writer.WriteString(" ");
            }
            else if(isAbstract)
            {
                writer.WriteKeyword("abstract");
                writer.WriteString(" ");
            }
            writer.WriteKeyword("class");
            writer.WriteString(" ");
            writer.WriteString(name);
            WriteBaseClass(reflection, writer);
            WriteInterfaceList(reflection, writer);
        }
        // class: done
		public override void WriteClassSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = (string) reflection.Evaluate(apiNameExpression);
			bool isAbstract = (bool) reflection.Evaluate(apiIsAbstractTypeExpression);
			bool isSealed = (bool) reflection.Evaluate(apiIsSealedTypeExpression);
			bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			if (isAbstract) {
				if (isSealed) {
					// static -- VB doesn't really handle this case
					writer.WriteKeyword("NotInheritable");
					writer.WriteString(" ");
				} else {
					writer.WriteKeyword("MustInherit");
					writer.WriteString(" ");
				}
			} else if (isSealed) {
				writer.WriteKeyword("NotInheritable");
				writer.WriteString(" ");
			}
			writer.WriteKeyword("Class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteBaseClass(reflection, writer);
			WriteImplementedInterfaces(reflection, writer);
		}
Ejemplo n.º 7
0
        public override void WriteSyntax (XPathNavigator reflection, SyntaxWriter writer) {

            string group = (string)reflection.Evaluate(groupExpression);
            string subgroup = (string)reflection.Evaluate(subgroupExpression);

            if (group == "type" && subgroup == "class") {
                string prefix = WebControlPrefix(reflection);
                if (!String.IsNullOrEmpty(prefix)) {
                    WriteClassSyntax(reflection, writer, prefix);
                }
            }

            if (group == "member") {

                string prefix = null;
                XPathNavigator containingType = reflection.SelectSingleNode(containingTypeExpression);
                if (containingType != null) prefix = WebControlPrefix(containingType);

                if (!String.IsNullOrEmpty(prefix)) {
                    if (subgroup == "property") {
                        WritePropertySyntax(reflection, writer, prefix);
                    } else if (subgroup == "event") {
                        WriteEventSyntax(reflection, writer, prefix);
                    }
                }
            }


        }
Ejemplo n.º 8
0
 public Category(XPathNavigator category, IXmlNamespaceResolver resolver)
 {
     this.Id = category.GetAttribute("id", String.Empty);
     this._index = Convert.ToInt32(category.Evaluate("count(preceding-sibling::c:category)", resolver));
     this._headerText = ((string)(category.GetAttribute("headerText", String.Empty)));
     this._description = ((string)(category.Evaluate("string(c:description)", resolver))).Trim();
     _tab = category.GetAttribute("tab", String.Empty);
     _newColumn = (category.GetAttribute("newColumn", String.Empty) == "true");
     _template = ((string)(category.Evaluate("string(c:template)", resolver)));
     _floating = (category.GetAttribute("floating", String.Empty) == "true");
     _collapsed = (category.GetAttribute("collapsed", String.Empty) == "true");
 }
        public override void WriteEnumerationSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

            string name = (string)reflection.Evaluate(apiNameExpression);
            bool isSerializable = (bool)reflection.Evaluate(apiIsSerializableTypeExpression);

            if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
            WriteAttributes(reflection, writer);
            writer.WriteKeyword("type");
            writer.WriteString(" ");
            WriteVisibility(reflection, writer);
            writer.WriteIdentifier(name);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Evaluates the given expression and returns the typed result.
 /// </summary>
 public static object Evaluate(string expression, XPathNavigator source,
     params XmlPrefix[] prefixes)
 {
     XPathExpression expr = GetCompiledExpression(expression, source);
     expr.SetContext(PrepareContext(source, null, prefixes, null));
     return source.Evaluate(expr);
 }
        public override void WriteNamespaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            string name = (string)reflection.Evaluate(apiNameExpression);

            writer.WriteKeyword("package");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);
        }
Ejemplo n.º 12
0
 /// <summary>
 /// Evaluates the given expression and returns the typed result.
 /// </summary>
 public static object Evaluate(string expression, XPathNavigator source,
     params XPathVariable[] variables)
 {
     XPathExpression expr = GetCompiledExpression(expression, source);
     expr.SetContext(PrepareContext(source, null, null, variables));
     return source.Evaluate(expr);
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Evaluates the given expression and returns the typed result.
 /// </summary>
 public static object Evaluate(string expression, XPathNavigator source,
     XmlNamespaceManager context)
 {
     XPathExpression expr = GetCompiledExpression(expression, source);
     expr.SetContext(context);
     return source.Evaluate(expr);
 }
        // structure: done
		public override void WriteStructureSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = (string) reflection.Evaluate(apiNameExpression);
			bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("struct");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteGenericTemplates(reflection, writer);
			WriteImplementedInterfaces(reflection, writer);
			WriteGenericTemplateConstraints(reflection, writer);

		}
 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     string str = XPathMessageFunction.ToString(args[0]);
     string xpath = string.Format(CultureInfo.InvariantCulture, "/s11:Envelope/s11:Header/*[@s11:actor='{0}'] | /s12:Envelope/s12:Header/*[@s12:role='{1}']", new object[] { str, str });
     XPathExpression expr = docContext.Compile(xpath);
     expr.SetContext((XmlNamespaceManager) xsltContext);
     return docContext.Evaluate(expr);
 }
Ejemplo n.º 16
0
 private string WebControlPrefix (XPathNavigator reflection) {
     if ((bool)reflection.Evaluate(typeIsWebControl)) {
         string name = (string)reflection.Evaluate(nameExpression);
         string space = (string)reflection.Evaluate(containingNamespaceExpression);
         if ((space == "N:System.Web.UI") && ((name == "Page") || (name == "ScriptControl") || (name == "UserControl"))) {
             return (null);
         } else {
             if (space == "N:System.Web.UI.MobileControls") {
                 return ("mobile");
             } else {
                 return ("asp");
             }
         }
     } else {
         return (null);
     }
 }
        public override void WriteEnumerationSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            string name = (string)reflection.Evaluate(apiNameExpression);

            WriteAttributeList(reflection, writer);
            WriteAccessModifier(reflection, writer);
            writer.WriteKeyword("enum");
            writer.WriteString(" ");
            writer.WriteString(name);
            // no JScript support for underlying types
        }
 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(/s11:Envelope/s11:Body | /s12:Envelope/s12:Body)[1]");
         expression.SetContext(XPathMessageFunction.Namespaces);
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
 public override object Invoke(XsltContext xsltContext, object[] args, XPathNavigator docContext)
 {
     if (this.expr == null)
     {
         XPathExpression expression = docContext.Compile("(sm:header()/wsa10:FaultTo | sm:header()/wsaAugust2004:FaultTo)[1]");
         expression.SetContext((XmlNamespaceManager) new XPathMessageContext());
         this.expr = expression;
     }
     return docContext.Evaluate(this.expr);
 }
        public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            if (IsUnsupportedGeneric(reflection, writer)) return;

            string name = (string)reflection.Evaluate(apiNameExpression);

            WriteAttributeList(reflection, writer);
            WriteAccessModifier(reflection, writer);
            writer.WriteKeyword("interface");
            writer.WriteString(" ");
            writer.WriteString(name);
            WriteInterfaceList("extends", reflection, writer);
        }
 protected object Evaluate(XPathNavigator nav)
 {
     SeekableMessageNavigator navigator = nav as SeekableMessageNavigator;
     if (navigator != null)
     {
         navigator.Atomize();
     }
     if (XPathResultType.NodeSet == this.xpath.ReturnType)
     {
         return nav.Select(this.xpath);
     }
     return nav.Evaluate(this.xpath);
 }
        // interface: done
		public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = (string) reflection.Evaluate(apiNameExpression);

			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("Interface");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
            WriteGenericTemplates(reflection, writer, true); // Need to write variance info for interfaces and delegates
			WriteImplementedInterfaces(reflection, writer);
		}
		public override void WriteStructureSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			if (IsUnsupportedGeneric(reflection, writer)) return;

			string name = (string) reflection.Evaluate(apiNameExpression);
			bool isSerializable = (bool) reflection.Evaluate(apiIsSerializableTypeExpression);

			if (isSerializable) WriteAttribute("T:System.SerializableAttribute", writer);
			WriteAttributes(reflection, writer);
			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("final");
			writer.WriteString(" ");
			writer.WriteKeyword("class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);

			writer.WriteString(" ");
			writer.WriteKeyword("extends");
			writer.WriteString(" ");
			writer.WriteReferenceLink("T:System.ValueType");

			WriteImplementedInterfaces(reflection, writer);
		}
        public override void WriteConstructorSyntax (XPathNavigator reflection, SyntaxWriter writer) {
            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);
            if (isStatic) {
                writer.WriteMessage("UnsupportedStaticConstructor_" + Language);
            } else {
                if (IsUnsupportedUnsafe(reflection, writer)) return;
                XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);

                WriteAttributeList(reflection, writer);
                WriteAccessModifier(reflection, writer);
                writer.WriteKeyword("function");
                writer.WriteString(" ");
                WriteTypeReference(declaringType, writer);
                WriteParameterList(reflection, writer);
            }
        }
		public override void WriteInterfaceSyntax (XPathNavigator reflection, SyntaxWriter writer) {

			string name = (string) reflection.Evaluate(apiNameExpression);

			WriteAttributes(reflection, writer);

			WriteGenericTemplates(reflection, writer);

			WriteVisibility(reflection, writer);
			writer.WriteString(" ");
			writer.WriteKeyword("interface class");
			writer.WriteString(" ");
			writer.WriteIdentifier(name);
			WriteImplementedInterfaces(reflection, writer);

		}
        /// <summary>
        /// Evaluates an XPath expression in a newly created context, making additional parameters available to the expression.
        /// </summary>
        /// <param name="nav">
        /// Navigator indicating the current node; if <c>null</c>, a dummy navigator is used.
        /// </param>
        /// <param name="xpathExpr">XPath expression to evaluate.</param>
        /// <param name="param">
        /// Values to be available while evaluating the expression as <c>$paramN</c>, where N is the
        /// index within this array.
        /// </param>
        /// <returns>The result of evaluating the expression</returns>
        public static object Evaluate(XPathNavigator nav, string xpathExpr, params object[] param)
        {
            Checker.NotNull(xpathExpr, "xpathExpr");

            nav = EnsureNavigator(nav);

            var expr = nav.Compile(xpathExpr);

            var context = new TriflesXPathContext();

            int i = 0;
            foreach (var paramN in param)
            {
                context.AddVariable(XNamespace.None + ("param" + i), paramN);
                i++;
            }

            expr.SetContext(context);
            return nav.Evaluate(expr);
        }
        protected object Evaluate(XPathNavigator nav)
        {
            SeekableMessageNavigator messageNav = nav as SeekableMessageNavigator;

            if (null != messageNav)
            {
                // If operating on messages, we would have avoided atomizing unless we were using the Framework
                // This ensures that atomization has taken place
                messageNav.Atomize();
            }

            object evalResult;
            if (XPathResultType.NodeSet == xpath.ReturnType)
            {
                evalResult = nav.Select(xpath);
            }
            else
            {
                evalResult = nav.Evaluate(xpath);
            }

            return evalResult;
        }
        private void TypeDeclaration (XPathNavigator reflection, SyntaxWriter writer, bool writeVariance) {
            string name = (string)reflection.Evaluate(apiNameExpression);
            XPathNavigator declaringType = reflection.SelectSingleNode(apiContainingTypeExpression);

            writer.WriteKeyword("Dim");
            writer.WriteString(" ");
            writer.WriteParameter("instance");
            writer.WriteString(" ");
            writer.WriteKeyword("As");
            writer.WriteString(" ");
            if (declaringType != null) {
                WriteTypeReference(declaringType, writer);
                writer.WriteString(".");
            }
            if (reservedWords.ContainsKey(name)) {
                writer.WriteString("[");
                writer.WriteIdentifier(name);
                writer.WriteString("]");
            } else {
                writer.WriteIdentifier(name);
            }
            WriteGenericTemplates(reflection, writer, writeVariance);
        }
        public override void WriteConstructorSyntax(XPathNavigator reflection, SyntaxWriter writer)
        {

            string name = (string)reflection.Evaluate(apiContainingTypeNameExpression);
            bool isStatic = (bool)reflection.Evaluate(apiIsStaticExpression);

            WriteAttributes(reflection, writer);

            writer.WriteKeyword("new");
            writer.WriteString(" : ");
            WriteParameters(reflection, writer);
            writer.WriteKeyword("->");
            writer.WriteString(" ");
            writer.WriteIdentifier(name);

        }
        private void WriteParameters(XPathNodeIterator parameters, XPathNavigator reflection, SyntaxWriter writer)
        {

            bool isExtension = (bool)reflection.Evaluate(apiIsExtensionMethod);
            writer.WriteLine();


            while (parameters.MoveNext())
            {
                XPathNavigator parameter = parameters.Current;

                string name = (string)parameter.Evaluate(parameterNameExpression);
                bool isOut = (bool)parameter.Evaluate(parameterIsOutExpression);
                bool isRef = (bool)parameter.Evaluate(parameterIsRefExpression);
                XPathNavigator type = parameter.SelectSingleNode(parameterTypeExpression);
                writer.WriteString("        ");
                writer.WriteParameter(name);
                writer.WriteString(":");
                WriteTypeReference(type, writer);
                if (isOut || isRef)
                {
                    writer.WriteString(" ");
                    writer.WriteKeyword("byref");
                }
                if (parameters.CurrentPosition != parameters.Count)
                {
                    writer.WriteString(" * ");
                    writer.WriteLine();
                }
                else
                {
                    writer.WriteString(" ");
                }
            }

        }