SelectSingleNode() публичный Метод

public SelectSingleNode ( XPathExpression expression ) : XPathNavigator
expression XPathExpression
Результат XPathNavigator
Пример #1
1
		public ForEachComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

            // set up the context
            XPathNodeIterator context_nodes = configuration.Select("context");
            foreach (XPathNavigator context_node in context_nodes)
            {
                string prefix = context_node.GetAttribute("prefix", String.Empty);
                string name = context_node.GetAttribute("name", String.Empty);
                context.AddNamespace(prefix, name);
            }

			// load the expression format
			XPathNavigator variable_node = configuration.SelectSingleNode("variable");
			if (variable_node == null) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify a variable using the <variable> element.");
			string xpath_format = variable_node.GetAttribute("expression", String.Empty);
			if ((xpath_format == null) || (xpath_format.Length == 0)) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify a variable expression using the expression attribute");
			xpath = XPathExpression.Compile(xpath_format);

			// load the subcomponents
			WriteMessage(MessageLevel.Info, "Loading subcomponents.");
			XPathNavigator components_node = configuration.SelectSingleNode("components");
			if (components_node == null) throw new ConfigurationErrorsException("When instantiating a ForEach component, you must specify subcomponents using the <components> element.");
			
			components = BuildAssembler.LoadComponents(components_node);

			WriteMessage(MessageLevel.Info, String.Format("Loaded {0} subcomponents.", components.Count));

		}
Пример #2
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;
                string sourcePath = patternNavigator.SelectSingleNode("@SourcePath").Value;
                string destPath = patternNavigator.SelectSingleNode("@DestinationPath").Value;
                string operationAsString = patternNavigator.SelectSingleNode("@Operation").Value;

                DTSTasks.FileSystemTask.DTSFileSystemOperation operation = DTSTasks.FileSystemTask.DTSFileSystemOperation.CopyDirectory;
                switch (operationAsString.ToUpperInvariant())
                {
                    case "COPYDIRECTORY":
                        operation = DTSTasks.FileSystemTask.DTSFileSystemOperation.CopyDirectory;
                        break;
                    default:
                        break;
                }

                FileSystemTask ft = new FileSystemTask(VulcanPackage, name, name, ParentContainer, sourcePath, destPath, operation);
                ft.SetExpression("OverwriteDestinationFile", "True");

                this.FirstExecutableGeneratedByPattern = ft.TaskHost;
                this.LastExecutableGeneratedByPattern = ft.TaskHost;
            }
        }
Пример #3
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string name = patternNavigator.SelectSingleNode("@Name").Value;

                string fileName =
                    Resources.Create+
                    name +
                    Resources.ExtensionSQLFile;

                string filePath = VulcanPackage.AddFileToProject(fileName);

                TableHelper th = new TableHelper(name, VulcanPackage.VulcanConfig, patternNavigator.SelectSingleNode("rc:Table",VulcanPackage.VulcanConfig.NamespaceManager));
                th.TraceHelper();

                th.TraceHelper();

                TableEmitterEx tex = new TableEmitterEx(th, VulcanPackage);

                tex.Emit(filePath,false);
                Connection connection = Connection.GetExistingConnection(VulcanPackage, patternNavigator);
                SQLTask sqlTask = new SQLTask(VulcanPackage,
                    Resources.Create + name,
                    Resources.Create + name,
                    ParentContainer,
                    connection
                    );

                sqlTask.TransmuteToFileTask(fileName);
                this.FirstExecutableGeneratedByPattern = sqlTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
            }
        }
Пример #4
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            string name = patternNavigator.SelectSingleNode("@Name").Value;
            string constraintMode = patternNavigator.SelectSingleNode("@ConstraintMode").Value;

            DTS.Sequence newParentContainer = VulcanPackage.AddSequenceContainer(name, ParentContainer);

            DTS.Executable previousExec = null;
            Pattern p = null;
            foreach (XPathNavigator nav in patternNavigator.SelectChildren(XPathNodeType.Element))
            {
                p = PatternFactory.ProcessPattern(VulcanPackage,newParentContainer, nav,p);

                switch (constraintMode)
                {
                    case "Linear":
                        VulcanPackage.AddPrecedenceConstraint(previousExec, p.FirstExecutableGeneratedByPattern, newParentContainer);
                        break;
                    case "Parallel":
                        break;
                    default:
                        Message.Trace(Severity.Error, "Unknown ConstraintMode {0}", constraintMode);
                        break;
                }
                previousExec = p.LastExecutableGeneratedByPattern;
            }
            this.FirstExecutableGeneratedByPattern = newParentContainer;
            this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
        }
Пример #5
0
        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            // Get the condition
            XPathNavigator if_node = configuration.SelectSingleNode("if");

            if(if_node == null)
                throw new ConfigurationErrorsException("You must specify a condition using the <if> element.");

            string condition_xpath = if_node.GetAttribute("condition", String.Empty);

            if(String.IsNullOrEmpty(condition_xpath))
                throw new ConfigurationErrorsException("You must define a condition attribute on the <if> element");

            condition = XPathExpression.Compile(condition_xpath);

            // Construct the true branch
            XPathNavigator then_node = configuration.SelectSingleNode("then");

            if(then_node != null)
                true_branch = BuildAssembler.LoadComponents(then_node);

            // Construct the false branch
            XPathNavigator else_node = configuration.SelectSingleNode("else");

            if(else_node != null)
                false_branch = BuildAssembler.LoadComponents(else_node);

            // Keep a pointer to the context for future use
            context = this.BuildAssembler.Context;
        }
Пример #6
0
        /// <summary>
        /// Parses the various properties from the XML document and populates the given SearchResult.
        /// </summary>
        /// <param name="result">The Google.CustomSearch.SearchResult to populate.</param>
        /// <param name="nav">The XPathNavigator for the response document.</param>
        private void ParseResponseProperties(SearchResult result, XPathNavigator nav)
        {
            XPathNavigator timeNode = nav.SelectSingleNode("/GSP/TM");
            if (timeNode != null)
                result.Time = timeNode.Value;

            XPathNavigator titleNode = nav.SelectSingleNode("/GSP/Context/title");
            if (titleNode != null)
                result.Title = titleNode.Value;

            XPathNavigator resultContainer = nav.SelectSingleNode("/GSP/RES");
            if (resultContainer != null)
            {
                // See http://www.google.com/cse/docs/resultsxml.html#results_xml_tag_XT
                result.Exact = resultContainer.SelectSingleNode("XT") != null;

                result.Filtered = resultContainer.SelectSingleNode("FI") != null;

                int startIndex;
                string start = resultContainer.GetAttribute("SN", string.Empty);
                if (int.TryParse(start, out startIndex))
                {
                    result.StartIndex = startIndex;
                }

                int endIndex;
                string end = resultContainer.GetAttribute("EN", string.Empty);
                if (int.TryParse(end, out endIndex))
                {
                    result.EndIndex = endIndex;
                }

                // Next and previous URLs
                XPathNavigator navigation = resultContainer.SelectSingleNode("NB");
                if (null != navigation)
                {
                    XPathNavigator nextLink = navigation.SelectSingleNode("NU");
                    if (null != nextLink)
                        result.NextPageLink = nextLink.Value;

                    XPathNavigator previousLink = navigation.SelectSingleNode("NP");
                    if (null != previousLink)
                        result.PreviousPageLink = previousLink.Value;
                }

                XPathNavigator totalNode = resultContainer.SelectSingleNode("M");
                if (totalNode != null)
                {
                    int total;
                    if (int.TryParse(totalNode.Value, out total))
                    {
                        result.Total = total;
                    }
                }
            }

            this.ParseSpellings(result, nav);

            this.ParseFacets(result, nav);
        }
Пример #7
0
 public ObsRequestNode(XPathNavigator nav)
 {
     ID = nav.SelectSingleNode ("@id").Value;
     Description = nav.SelectSingleNode ("description").Value;
     State = new RequestState (nav.SelectSingleNode ("state"));
     Action = new RequestAction (nav.SelectSingleNode ("action"));
 }
Пример #8
0
        internal Argument(XPathNavigator navigator, string nspace)
        {
            XmlNamespaceManager nsmanager = new XmlNamespaceManager(navigator.NameTable);
            nsmanager.AddNamespace("u", nspace);

            name = navigator.SelectSingleNode("u:name", nsmanager).Value;
            name = name.Trim();
            related = navigator.SelectSingleNode("u:relatedStateVariable", nsmanager).Value;
            related = related.Trim();
        }
        /// <summary>
        /// Populates the class members with data from the specified 
        /// active person information XML.
        /// </summary>
        /// 
        /// <param name="navigator">
        /// The XML to get the active person information from.
        /// </param>
        /// 
        internal override void ParseXml(XPathNavigator navigator)
        {
            base.ParseXml(navigator);

            Email = navigator.SelectSingleNode("contact-email").Value;

            RecordAuthorizationState = AuthorizedRecordState.Active;

            _name = navigator.SelectSingleNode("name").Value;
        }
Пример #10
0
 private ReferenceNode CreateNode(XPathNavigator nav)
 {
     var hintPathNode = nav.SelectSingleNode("n:HintPath", ns);
     var isPrivateNode = nav.SelectSingleNode("n:Private", ns);
     var name = GetSimpleReferenceName(nav.GetAttribute("Include", ""));
     return new ReferenceNode
                {
                    Include = name,
                    HintPath = hintPathNode == null ? string.Empty : hintPathNode.Value,
                    IsPrivate = isPrivateNode == null ? GetDefaultPrivateValue(name) : bool.Parse(isPrivateNode.Value)
                };
 }
Пример #11
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            if (patternNavigator != null)
            {
                string firstOrLast = patternNavigator.SelectSingleNode("@FirstOrLast").Value;
                string status = patternNavigator.SelectSingleNode("@Status").Value;
                string notes = patternNavigator.SelectSingleNode("@Notes").Value;

                Connection tableConnection =
                    Connection.GetExistingConnection(VulcanPackage, LogtainerPattern.CurrentLog.TableConnectionName);

                string execSqlTaskName = LogtainerPattern.CurrentLog.LogName + Resources.Seperator + firstOrLast + Guid.NewGuid();
                TemplateEmitter te = new TemplateEmitter(VulcanPackage.TemplateManager["LogSelectQuery"]);
                if (
                    LogtainerPattern.CurrentLog.SourceColumn == null ||
                    LogtainerPattern.CurrentLog.DestinationColumn == null ||
                    LogtainerPattern.CurrentLog.TableConnectionName == null ||
                    LogtainerPattern.CurrentLog.Table == null)
                {
                    Message.Trace(Severity.Error,
                        "Could not perform LogUpdate (On Log: {0}), Parent Logtainer does not contain all of the necessary information.  Needs SourceColumn, DestinationColumn, TableConnectionName, and Table attributes.",LogtainerPattern.CurrentLog.LogName);
                    return;
                }

                te.SetNamedParameter("Source", LogtainerPattern.CurrentLog.SourceColumn);
                te.SetNamedParameter("Destination", LogtainerPattern.CurrentLog.DestinationColumn);
                te.SetNamedParameter("Table", LogtainerPattern.CurrentLog.Table);
                te.SetNamedParameter("Status", status);
                te.SetNamedParameter("Notes", notes);
                te.SetNamedParameter("SourceConvertStyle", "21");
                te.SetNamedParameter("DestinationConvertStyle", "21");

                string query;
                te.Emit(out query);

                SQLTask readForLogTask = new SQLTask(VulcanPackage, execSqlTaskName, execSqlTaskName, ParentContainer, tableConnection);
                readForLogTask.TransmuteToExpressionTask(String.Format("\"{0}\"", query));
                readForLogTask.ExecuteSQLTask.ResultSetType = Microsoft.SqlServer.Dts.Tasks.ExecuteSQLTask.ResultSetType.ResultSetType_SingleRow;

                DTS.Variable sourceVar = LogtainerPattern.CurrentLog[firstOrLast+"SourceRecord"];
                DTS.Variable destVar = LogtainerPattern.CurrentLog[firstOrLast+"DestinationRecord"];
                DTS.Variable statusVar = LogtainerPattern.CurrentLog["Status"];
                DTS.Variable notesVar = LogtainerPattern.CurrentLog["Notes"];

                readForLogTask.BindResult("0", sourceVar.QualifiedName);
                readForLogTask.BindResult("1", destVar.QualifiedName);
                readForLogTask.BindResult("2", statusVar.QualifiedName);
                readForLogTask.BindResult("3", notesVar.QualifiedName);

                this.FirstExecutableGeneratedByPattern = readForLogTask.SQLTaskHost;
                this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
            }
        }
        /// <summary>
        /// Initializes the syndication extension context using the supplied <see cref="XPathNavigator"/>.
        /// </summary>
        /// <param name="source">The <b>XPathNavigator</b> used to load this <see cref="SDataExtensionContext"/>.</param>
        /// <param name="manager">The <see cref="XmlNamespaceManager"/> object used to resolve prefixed syndication extension elements and attributes.</param>
        /// <returns><b>true</b> if the <see cref="SDataExtensionContext"/> was able to be initialized using the supplied <paramref name="source"/>; otherwise <b>false</b>.</returns>
        /// <exception cref="ArgumentNullException">The <paramref name="source"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="manager"/> is a null reference (Nothing in Visual Basic).</exception>
        public bool Load(XPathNavigator source, XmlNamespaceManager manager)
        {
            //------------------------------------------------------------
            //	Local members
            //------------------------------------------------------------
            var wasLoaded = false;

            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(source, "source");
            Guard.ArgumentNotNull(manager, "manager");

            //------------------------------------------------------------
            //	Attempt to extract syndication extension information
            //------------------------------------------------------------
            if (source.HasChildren)
            {
                var syncModeNavigator = source.SelectSingleNode("sync:syncMode", manager);
                if (syncModeNavigator != null && !string.IsNullOrEmpty(syncModeNavigator.Value))
                {
                    SyncMode = (SyncMode) Enum.Parse(typeof (SyncMode), syncModeNavigator.Value, true);
                    wasLoaded = true;
                }

                var digestNavigator = source.SelectSingleNode("sync:digest", manager);
                if (digestNavigator != null)
                {
                    var digest = new Digest();
                    if (digest.Load(digestNavigator, manager))
                    {
                        Digest = digest;
                        wasLoaded = true;
                    }
                }

                var syncStateNavigator = source.SelectSingleNode("sync:syncState", manager);
                if (syncStateNavigator != null)
                {
                    var syncState = new SyncState();
                    if (syncState.Load(syncStateNavigator, manager))
                    {
                        SyncState = syncState;
                        wasLoaded = true;
                    }
                }
            }

            return wasLoaded;
        }
Пример #13
0
        public ZoneGroup(Discover disc, XPathNavigator node)
        {
            _coordinator = node.SelectSingleNode("@Coordinator").Value;
            _id = node.SelectSingleNode("@ID").Value;

            foreach (XPathNavigator nav in node.Select("ZoneGroupMember"))
            {
                ZonePlayer zp = disc.Intern(String.Concat("uuid:", nav.SelectSingleNode("@UUID").Value));
                _members.Add(zp);
            }

            _coordinatorZone = disc.Intern(String.Concat("uuid:", _coordinator));
            _members.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(_members_CollectionChanged);
        }
		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);

		}
Пример #15
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);
                    }
                }
            }


        }
Пример #16
0
        //=====================================================================

        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            // get the condition
            XPathNavigator condition_element = configuration.SelectSingleNode("switch");

            if(condition_element == null)
                throw new ConfigurationErrorsException("You must specify a condition using the <switch> statement with a 'value' attribute.");

            string condition_value = condition_element.GetAttribute("value", String.Empty);

            if(String.IsNullOrEmpty(condition_value))
                throw new ConfigurationErrorsException("The switch statement must have a 'value' attribute, which is an xpath expression.");

            condition = XPathExpression.Compile(condition_value);

            // load the component stacks for each case
            XPathNodeIterator case_elements = configuration.Select("case");

            foreach(XPathNavigator case_element in case_elements)
            {
                string case_value = case_element.GetAttribute("value", String.Empty);

                cases.Add(case_value, BuildAssembler.LoadComponents(case_element));
            }
        }
Пример #17
0
        public static string GetNodeValue(XPathNavigator node, string query)
        {
            if (node == null) return "N/A";

            var rtnNode = node.SelectSingleNode(query);
            return rtnNode == null ? "N/A" : rtnNode.Value.Trim();
        }
 private void ReadLegacyManifest(XPathNavigator legacyManifest, bool processModule)
 {
     XPathNavigator folderNav = legacyManifest.SelectSingleNode("folders/folder");
     if (processModule)
     {
         Package.Name = Util.ReadElement(folderNav, "name");
         Package.FriendlyName = Package.Name;
         foreach (XPathNavigator controlNav in folderNav.Select("modules/module/controls/control"))
         {
             SkinControl.ControlKey = Util.ReadElement(controlNav, "key");
             SkinControl.ControlSrc = Path.Combine(Path.Combine("DesktopModules", Package.Name.ToLower()), Util.ReadElement(controlNav, "src")).Replace("\\", "/");
             string supportsPartialRendering = Util.ReadElement(controlNav, "supportspartialrendering");
             if (!string.IsNullOrEmpty(supportsPartialRendering))
             {
                 SkinControl.SupportsPartialRendering = bool.Parse(supportsPartialRendering);
             }
         }
     }
     foreach (XPathNavigator fileNav in folderNav.Select("files/file"))
     {
         string fileName = Util.ReadElement(fileNav, "name");
         string filePath = Util.ReadElement(fileNav, "path");
         AddFile(Path.Combine(filePath, fileName), fileName);
     }
     if (!string.IsNullOrEmpty(Util.ReadElement(folderNav, "resourcefile")))
     {
         AddFile(Util.ReadElement(folderNav, "resourcefile"));
     }
 }
Пример #19
0
 public string Value(XPathNavigator node, string xpath)
 {
     XPathNavigator n = node.SelectSingleNode(xpath, ns);
     if (n == null)
         throw new InvalidStructureException("Missing value in profile: {0}", xpath);
     return n.Value;
 }
Пример #20
0
        public static DerivedColumns CreateDerivedColumnsFromXml(Packages.VulcanPackage vulcanPackage, IDTSComponentMetaData90 parentComponent, MainPipe dataFlowTask, XPathNavigator derivedNav)
        {
            if (derivedNav == null || derivedNav.Name.ToUpperInvariant() != "DerivedColumns".ToUpperInvariant())
            {
                //We don't handle this.
                return null;
            }

            string componentName = derivedNav.SelectSingleNode("@Name", vulcanPackage.VulcanConfig.NamespaceManager).Value;
            Message.Trace(Severity.Debug, "Begin: DerivedColumns Transformation {0}", componentName);

            DerivedColumns dc = new DerivedColumns(vulcanPackage, dataFlowTask, parentComponent, componentName, componentName);

            foreach (XPathNavigator nav in derivedNav.Select("rc:Column", vulcanPackage.VulcanConfig.NamespaceManager))
            {
                string colName = nav.SelectSingleNode("@Name").Value;
                string typeAsString = nav.SelectSingleNode("@Type").Value;
                int length = nav.SelectSingleNode("@Length").ValueAsInt;
                int precision = nav.SelectSingleNode("@Precision").ValueAsInt;
                int scale = nav.SelectSingleNode("@Scale").ValueAsInt;
                int codepage = nav.SelectSingleNode("@Codepage").ValueAsInt;

                string expression = nav.Value;

                DataType type = TransformationFactory.GetDataTypeFromString(typeAsString);

                dc.AddOutputColumn(colName, type, expression, length, precision, scale, codepage);
            }
            return dc;
        }
        private static string GetChildValueOrDefault(XPathNavigator node, string childExpression)
        {
            if (node == null) return null;

            var childNode = node.SelectSingleNode(childExpression);
            return (childNode == null) ? null : childNode.Value.Trim();
        }
Пример #22
0
        public void ReadPath(Element element, XPathNavigator node)
        {
            string s = node.SelectSingleNode("f:path/@value", ns).Value;

            element.Path = new Path(s);
            element.Name = element.Path.ElementName;
        }
		public IntellisenseComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

			XPathNavigator output_node = configuration.SelectSingleNode("output");
			if (output_node != null) {
                
				string directory_value = output_node.GetAttribute("directory", String.Empty);
				if (!String.IsNullOrEmpty(directory_value)) {
					directory = Environment.ExpandEnvironmentVariables(directory_value);
					if (!Directory.Exists(directory)) WriteMessage(MessageLevel.Error, String.Format("The output directory '{0}' does not exist.", directory));
				}
			}

            // a way to get additional information into the intellisense file
            XPathNodeIterator input_nodes = configuration.Select("input");
            foreach (XPathNavigator input_node in input_nodes) {
                string file_value = input_node.GetAttribute("file", String.Empty);
                if (!String.IsNullOrEmpty(file_value)) {
                    string file = Environment.ExpandEnvironmentVariables(file_value);
                    ReadInputFile(file);
                }
            }

			context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");

			summaryExpression.SetContext(context);
            memberSummaryExpression.SetContext(context);
			returnsExpression.SetContext(context);
			parametersExpression.SetContext(context);
			parameterNameExpression.SetContext(context);
            templatesExpression.SetContext(context);
            templateNameExpression.SetContext(context);
            exceptionExpression.SetContext(context);
            exceptionCrefExpression.SetContext(context);
        }
Пример #24
0
		public SaveComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

			// load the target path format
			XPathNavigator save_node = configuration.SelectSingleNode("save");
			if (save_node == null) throw new ConfigurationErrorsException("When instantiating a save component, you must specify a the target file using the <save> element.");

			string base_value = save_node.GetAttribute("base", String.Empty);
			if (!String.IsNullOrEmpty(base_value)) {
				basePath = Path.GetFullPath(Environment.ExpandEnvironmentVariables(base_value));
			}

			string path_value = save_node.GetAttribute("path", String.Empty);
			if (String.IsNullOrEmpty(path_value)) WriteMessage(MessageLevel.Error, "Each save element must have a path attribute specifying an XPath that evaluates to the location to save the file.");
			path_expression = XPathExpression.Compile(path_value);

            string select_value = save_node.GetAttribute("select", String.Empty);
            if (!String.IsNullOrEmpty(select_value))
                select_expression = XPathExpression.Compile(select_value);

            settings.Encoding = Encoding.UTF8;

			string indent_value = save_node.GetAttribute("indent", String.Empty);
			if (!String.IsNullOrEmpty(indent_value)) settings.Indent = Convert.ToBoolean(indent_value);

			string omit_value = save_node.GetAttribute("omit-xml-declaration", String.Empty);
			if (!String.IsNullOrEmpty(omit_value)) settings.OmitXmlDeclaration = Convert.ToBoolean(omit_value);

            linkPath = save_node.GetAttribute("link", String.Empty);
            if (String.IsNullOrEmpty(linkPath)) linkPath = "../html";

			// encoding

			settings.CloseOutput = true;

		}
Пример #25
0
        public static bool GetXmlBoolValue(XPathNavigator parentNode, string valueName, bool emptyIsTrue)
        {
            if (parentNode == null || string.IsNullOrEmpty(valueName))
            {
                return false;
            }
            bool result = false;

            try
            {
                XPathNavigator node = parentNode.SelectSingleNode(valueName);
                if (emptyIsTrue)
                {
                    result = (node == null || (node != null && node.Value == "yes" && string.IsNullOrEmpty(node.Value)));
                }
                else
                {
                    result = (node != null && node.Value == "yes");
                }
            }
            catch (NullReferenceException)
            {
            }
            return result;
        }
Пример #26
0
        public override void Emit(XPathNavigator patternNavigator)
        {
            string containerName = patternNavigator.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;
            string helperTableTaskName = "Set Up Helper Table Group "+containerName;

            string helperTableFile = containerName + Resources.ExtensionSQLFile;
            string helperTableFilePath = VulcanPackage.AddFileToProject(helperTableFile);

            File.Delete(helperTableFilePath);

            Connection c = Connection.GetExistingConnection(VulcanPackage, patternNavigator);

            foreach (XPathNavigator nav in patternNavigator.Select("rc:HelperTable", VulcanPackage.VulcanConfig.NamespaceManager))
            {
                string tableName = nav.SelectSingleNode("@Name", VulcanPackage.VulcanConfig.NamespaceManager).Value;
                XPathNavigator tableNavigator = nav.SelectSingleNode("rc:Table",VulcanPackage.VulcanConfig.NamespaceManager);
                Message.Trace(Severity.Debug,"Adding Helper table "+tableName);

                TableHelper th = new TableHelper(tableName, VulcanPackage.VulcanConfig, tableNavigator);
                TableEmitterEx te = new TableEmitterEx(th,VulcanPackage);
                te.Emit(VulcanPackage.QualifiedProjectPath+helperTableFile, true);
            }

            SQLTask setupSQLTask = new SQLTask(VulcanPackage, helperTableTaskName, helperTableTaskName, ParentContainer,c);
            setupSQLTask.TransmuteToFileTask(helperTableFile);

            this.ExecuteDuringDesignTime(patternNavigator, setupSQLTask.SQLTaskHost);

            this.FirstExecutableGeneratedByPattern = setupSQLTask.SQLTaskHost;
            this.LastExecutableGeneratedByPattern = this.FirstExecutableGeneratedByPattern;
        }
Пример #27
0
        //=====================================================================

        /// <inheritdoc />
        /// <remarks>If an <c>xpath</c> element is found in the configuration, it's inner text will be used as
        /// a filter expression to select elements to dump.  If not found, the entire document is dumped.   The
        /// expression can have a single replacement parameter (<c>{0}</c>).  If present, it will be replaced
        /// with the current document key.</remarks>
        public override void Initialize(XPathNavigator configuration)
        {
            XPathNavigator xpathFormatNode = configuration.SelectSingleNode("xpath");

            if(xpathFormatNode != null)
                xpathFormat = xpathFormatNode.Value;
        }
Пример #28
0
    // ------------------------------------------
    //  Audio Management
    // ------------------------------------------

    public override void BeforeSpeechRecognition(string device, string text, double confidence, XPathNavigator xnav, string grammar, Stream stream, IDictionary<string, string> options) {
      base.BeforeSpeechRecognition(device, text, confidence, xnav, grammar, stream, options);

      var tts = xnav.SelectSingleNode("/SML/action/@tts");
      if (tts != null) {
        AddOnManager.GetInstance().BeforeHandleVoice(tts.Value, true);
      }
    }
        /// <inheritdoc />
        public override void Initialize(XPathNavigator configuration)
        {
            base.Initialize(configuration);

            var lineCont = configuration.SelectSingleNode("includeLineContinuation/@value");

            if(lineCont == null || !Boolean.TryParse(lineCont.Value, out includeLineContinuation))
                includeLineContinuation = false;
        }
Пример #30
-1
        public LiveExampleComponent(BuildAssembler assembler, XPathNavigator configuration)
            : base(assembler, configuration) {

            XPathNavigator parsnip_node = configuration.SelectSingleNode("parsnip");
            string approvedFile = null;
            if (parsnip_node != null) {
                approvedFile = parsnip_node.GetAttribute("approved-file", String.Empty);

                string omitBadExamplesValue = parsnip_node.GetAttribute("omit-bad-examples", String.Empty);
                if (!string.IsNullOrEmpty(omitBadExamplesValue))
                    omitBadExamples = Boolean.Parse(omitBadExamplesValue);

                //string runBadExamplesValue = parsnip_node.GetAttribute("run-bad-examples", String.Empty);
                //if (!string.IsNullOrEmpty(runBadExamplesValue))
                //    runBadExamples = Boolean.Parse(runBadExamplesValue);
            }

            if (string.IsNullOrEmpty(approvedFile))
                WriteMessage(MessageLevel.Warn, "No approved samples file specified; all available samples will be included.");
            else
                LoadApprovedFile(approvedFile);

            context = new CustomContext();
            context.AddNamespace("ddue", "http://ddue.schemas.microsoft.com/authoring/2003/5");

            selector = XPathExpression.Compile("//ddue:codeReference");
            selector.SetContext(context);
        }