Select() public method

public Select ( XPathExpression expr ) : XPathNodeIterator
expr XPathExpression
return XPathNodeIterator
コード例 #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 BusinessRulesNode(XPathNavigator node, object aSetId)
        {
            XPathNodeIterator selectedNodes;
            if (aSetId == null)
                selectedNodes = node.Select("*[count(ancestor-or-self::" + SET + ")=0]");
            else
                selectedNodes = node.Select("*[count(ancestor-or-self::" + SET + ")=0] | " + SET + "[@" + SET_ATTRS.ID + "='" + aSetId + "']/*");

            PopulateSubNodes(selectedNodes, aSetId);
        }
コード例 #3
0
ファイル: RssFetcher.cs プロジェクト: nnovic/GetFacts
 protected override XPathNodeIterator CreateArticlesIterator(Site s, XPathNavigator navigator)
 {
     // RSS
     XPathNodeIterator output = navigator.Select("/rss/channel/item");
     if (output.Count == 0)
     {
         // ATOM
         output = navigator.Select("/atom:feed/atom:entry", xmlnsManager);
     }
     return output;
 }
コード例 #4
0
		public SharedContentComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

			// get context
			context = GetContext(configuration);

			// get the tags to be resolved
			XPathNodeIterator resolve_nodes = configuration.Select("replace");
			foreach (XPathNavigator resolve_node in resolve_nodes) {
				string path = resolve_node.GetAttribute("elements", String.Empty);
				if (String.IsNullOrEmpty(path)) path = "//(include|includeAttribute)";
				// if (String.IsNullOrEmpty(path)) WriteMessage(MessageLevel.Error, "Each resolve element must contain a path attribute specifying an XPath expression for shared content elements.");
				try {
					XPathExpression path_expresion = XPathExpression.Compile(path, context);
				} catch (XPathException) {
					WriteMessage(MessageLevel.Error, String.Format("The elements expression '{0}' is not a valid XPath.", path));
				}

				string item = resolve_node.GetAttribute("item", String.Empty);
				if (String.IsNullOrEmpty(item)) item = "string(@item)";
				try {
					XPathExpression item_expression = XPathExpression.Compile(item, context);
				} catch (XPathException) {
					WriteMessage(MessageLevel.Error, String.Format("The item expression '{0}' is not a valid XPath.", item));
				}

				string parameters = resolve_node.GetAttribute("parameters", String.Empty);
				if (String.IsNullOrEmpty(parameters)) parameters = "parameter";

				string attribute = resolve_node.GetAttribute("attribute", String.Empty);
				if (String.IsNullOrEmpty(attribute)) attribute = "string(@name)";

				elements.Add( new SharedContentElement(path, item, parameters, attribute, context) );
			}

			// Console.WriteLine("{0} elements explicitly defined", elements.Count);

			if (elements.Count == 0) elements.Add( new SharedContentElement(@"//include | //includeAttribute", "string(@item)", "parameter", "string(@name)", context) );

			// get the source and target formats
			XPathNodeIterator content_nodes = configuration.Select("content");
			foreach (XPathNavigator content_node in content_nodes)
            {
                // get the files				
                string sharedContentFiles = content_node.GetAttribute("file", String.Empty);
                if (String.IsNullOrEmpty(sharedContentFiles))
                    WriteMessage(MessageLevel.Error, "The content/@file attribute must specify a path.");
                ParseDocuments(sharedContentFiles);
            }
            WriteMessage(MessageLevel.Info, String.Format("Loaded {0} shared content items.", content.Count));
		}
コード例 #5
0
ファイル: ConfigBlockNodeHandler.cs プロジェクト: nobled/mono
		public void ReadConfiguration (XPathNavigator nav)
		{
			name = Helpers.GetRequiredNonEmptyAttribute (nav, "name");
			
			requirements = new Section ();
			Helpers.BuildSectionTree (nav.Select ("requires/section[string-length(@name) > 0]"), requirements);

			XPathNodeIterator iter = nav.Select ("contents/text()");
			StringBuilder sb = new StringBuilder ();
			
			while (iter.MoveNext ())
				sb.Append (iter.Current.Value);
			if (sb.Length > 0)
				contents = sb.ToString ();
		}
コード例 #6
0
		public CopyFromFileComponent (BuildAssembler assembler, XPathNavigator configuration) : base(assembler, configuration) {

			if (configuration == null) throw new ArgumentNullException("configuration");

			string data_name = null;

			// get information about the data file
			XPathNodeIterator data_nodes = configuration.Select("data");
			foreach (XPathNavigator data_node in data_nodes) {
				string data_file = data_node.GetAttribute("file", String.Empty);
				if (String.IsNullOrEmpty(data_file)) WriteMessage(MessageLevel.Error, "Data elements must have a file attribute specifying a file from which to load data.");
				data_file = Environment.ExpandEnvironmentVariables(data_file);

				data_name = data_node.GetAttribute("name", String.Empty);
				if (String.IsNullOrEmpty(data_name)) data_name = Guid.NewGuid().ToString();

				// load a schema, if one is specified
				string schema_file = data_node.GetAttribute("schema", String.Empty);
				XmlReaderSettings settings = new XmlReaderSettings();
				if (!String.IsNullOrEmpty(schema_file)) {
					settings.Schemas.Add(null, schema_file);
				}

				// load the document
				WriteMessage(MessageLevel.Info, String.Format("Loading data file '{0}'.", data_file) );
				using (XmlReader reader = XmlReader.Create(data_file, settings)) {
					XPathDocument data_document = new XPathDocument(reader);
					Data.Add(data_name, data_document);
				}
			}
			

			// get the source and target expressions for each copy command
			XPathNodeIterator copy_nodes = configuration.Select("copy");
			foreach (XPathNavigator copy_node in copy_nodes) {
				string source_name = copy_node.GetAttribute("name", String.Empty);
				if (String.IsNullOrEmpty(source_name)) source_name = data_name;

				XPathDocument source_document = (XPathDocument) Data[source_name];

				string source_xpath = copy_node.GetAttribute("source", String.Empty);
				if (String.IsNullOrEmpty(source_xpath)) throw new ConfigurationErrorsException("When instantiating a CopyFromFile component, you must specify a source xpath format using the source attribute.");
				string target_xpath = copy_node.GetAttribute("target", String.Empty);
				if (String.IsNullOrEmpty(target_xpath)) throw new ConfigurationErrorsException("When instantiating a CopyFromFile component, you must specify a target xpath format using the target attribute.");
				copy_commands.Add( new CopyFromFileCommand(source_document, source_xpath, target_xpath) );
			}

		}
コード例 #7
0
ファイル: HelperTablePattern.cs プロジェクト: japj/vulcan
        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;
        }
コード例 #8
0
		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);
        }
        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodThatDeclaresLocalsAfterEmittingOpcodes.SimpleClass.ReflectArgument\"]/sequencepoints/entry");
            Assert.Equal(6, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("16", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x5")
                {
                    Assert.Equal("21", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodThatWritesLotsOfLocalsToTheConsole.SimpleClass.WriteToConsole\"]/sequencepoints/entry");
            Assert.Equal(6, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("18", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("76", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x38")
                {
                    Assert.Equal("31", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("31", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
コード例 #11
0
        /// <summary>
        /// Récupère la valeur de l'attribut du noeud recherché dans le fichier de configuration
        /// </summary>
        /// <param name="xPathString">Expression XPath de recherche du noeud</param>
        /// <param name="attribute">Attribut à rechercher</param>
        /// <returns>Une ArrayList contenant la liste des attributs recherchés</returns>
        public ArrayList GetAttributes(string xPathString, string attribute)
        {
            // Initilisation des variables
                    XPathNodeIterator xpathNodeIterator;
                    XPathExpression expr;

                    ArrayList attributes = new ArrayList();

                    // Parcours du fichier XML
                    try
                    {
                           xpathNavigator = xpathDoc.CreateNavigator();
                           expr = xpathNavigator.Compile(xPathString);
                           xpathNodeIterator = xpathNavigator.Select(expr);

                           while (xpathNodeIterator.MoveNext())
                           {
                                  // On récupère l'attribut
                                  attributes.Add(xpathNodeIterator.Current.GetAttribute(attribute, ""));
                           }
                    }
                    catch (Exception e)
                    {
                    }

                    return attributes;
        }
        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodWithFilteredExceptionHandler.SimpleClass.DivideWithFilter\"]/sequencepoints/entry");
            Assert.Equal(14, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("18", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("18", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("5", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("22", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x1e")
                {
                    Assert.Equal("38", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("38", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
コード例 #13
0
ファイル: Language.cs プロジェクト: BGCX261/zlap-svn-to-git
 public XPathNodeIterator GetLanguageByName(string name)
 {
     XPathDocument doc = new XPathDocument(this.language_support_file);
     nav = doc.CreateNavigator();
     XPathNodeIterator nodes = nav.Select("/lang_support/lang[name='" + name + "']");
     return nodes;
 }
コード例 #14
0
ファイル: Language.cs プロジェクト: BGCX261/zlap-svn-to-git
 public XPathNodeIterator GetLanguage()
 {
     XPathDocument doc = new XPathDocument(this.language_support_file);
     nav = doc.CreateNavigator();
     XPathNodeIterator nodes = nav.Select("/lang_support/lang");
     return nodes;
 }
コード例 #15
0
ファイル: VSResxData.cs プロジェクト: dnstech/ResxManager
        public VSResxData(VSResxFile file, XPathNavigator nav)
            : base(file)
        {
            Name = nav.GetAttribute("name", "");

            XPathNodeIterator values = nav.Select("value");
            if (values.MoveNext())
            {
                xmlValue = values.Current.Value;
            }
            values = nav.Select("comment");
            if (values.MoveNext())
            {
                comment = values.Current.Value;
            }
        }
コード例 #16
0
        private SatoriDhcpOsFingerprinter(System.IO.Stream fingerprintXmlStream)
        {
            fingerprintList = new List <DhcpFingerprint>();

            System.Xml.XmlDocument dhcpXml = new System.Xml.XmlDocument();
            dhcpXml.Load(fingerprintXmlStream);
            XmlNode fingerprintsNode = dhcpXml.DocumentElement.FirstChild;

            //System.Xml.XPath.XPathNavigator navigator=dhcpXml.CreateNavigator();
            System.Xml.XPath.XPathNavigator navigator = fingerprintsNode.CreateNavigator();
            foreach (XPathNavigator fingerprintNavigator in navigator.Select("fingerprint"))
            {
                string osClass = fingerprintNavigator.GetAttribute("os_class", "");
                string os      = fingerprintNavigator.GetAttribute("os_name", "");
                if (os == null || os.Length == 0)
                {
                    os = fingerprintNavigator.GetAttribute("name", "");
                }
                string deviceType   = fingerprintNavigator.GetAttribute("device_type", "");
                string deviceVendor = fingerprintNavigator.GetAttribute("device_vendor", "");
                //string os=fingerprintNavigator.GetAttribute("os","");
                DhcpFingerprint fingerprint = new DhcpFingerprint(os, osClass, deviceType, deviceVendor);
                this.fingerprintList.Add(fingerprint);

                foreach (XPathNavigator testNav in fingerprintNavigator.Select("dhcp_tests/test")) //used to be "tests/test"
                {
                    fingerprint.AddTest(testNav.Clone());
                }
            }
        }
コード例 #17
0
ファイル: FeatureAction.cs プロジェクト: nobled/mono
		public FeatureAction (XPathNavigator nav)
		{
			string val = Helpers.GetRequiredNonEmptyAttribute (nav, "type");
			type = Helpers.ConvertEnum <ActionType> (val, "type");

			val = Helpers.GetRequiredNonEmptyAttribute (nav, "when");
			when = Helpers.ConvertEnum <ActionWhen> (val, "when");

			XPathNodeIterator iter;
			StringBuilder sb = new StringBuilder ();
			
			switch (type) {
				case ActionType.Message:
				case ActionType.ShellScript:
					iter = nav.Select ("./text()");
					while (iter.MoveNext ())
						sb.Append (iter.Current.Value);
					if (type == ActionType.Message)
						message = sb.ToString ();
					else
						script = sb.ToString ();
					break;
					
				case ActionType.Exec:
					command = Helpers.GetRequiredNonEmptyAttribute (nav, "command");
					commandArguments = Helpers.GetOptionalAttribute (nav, "commndArguments");
					break;
			}
		}
コード例 #18
0
ファイル: TransformationFactory.cs プロジェクト: japj/vulcan
        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;
        }
コード例 #19
0
        internal SatoriTcpOsFingerprinter(string satoriTcpXmlFilename)
        {
            fingerprintList = new List <TcpFingerprint>();
            System.IO.FileStream fileStream = new FileStream(satoriTcpXmlFilename, FileMode.Open, FileAccess.Read);

            System.Xml.XmlDocument tcpXml = new System.Xml.XmlDocument();
            tcpXml.Load(fileStream);
            XmlNode fingerprintsNode = tcpXml.DocumentElement.FirstChild;

            //System.Xml.XPath.XPathNavigator navigator=tcpXml.CreateNavigator();
            System.Xml.XPath.XPathNavigator navigator = fingerprintsNode.CreateNavigator();
            foreach (XPathNavigator fingerprintNavigator in navigator.Select("fingerprint"))
            {
                string osClass = fingerprintNavigator.GetAttribute("os_class", "");
                string os      = fingerprintNavigator.GetAttribute("os_name", "");
                if (os == null || os.Length == 0)
                {
                    os = fingerprintNavigator.GetAttribute("name", "");
                }
                //string os=fingerprintNavigator.GetAttribute("os","");
                TcpFingerprint fingerprint = new TcpFingerprint(os, osClass);
                this.fingerprintList.Add(fingerprint);
                foreach (XPathNavigator testNav in fingerprintNavigator.Select("tcp_tests/test")) //used to be "tests/test"
                {
                    fingerprint.AddTest(testNav.Clone());
                }
            }
        }
コード例 #20
0
ファイル: MdlAutoKeys.cs プロジェクト: quadrowin/afkgamer
 public override void LoadFromXml(XPathNavigator xml, string prefix)
 {
     XPathNodeIterator iterator = xml.Select(
         prefix + GetType().FullName + "/" + GetType().Namespace + ".KeyTimer"
     );
     int i = 0;
     while (iterator.MoveNext())
     {
         if (i >= KeyTimers.Count)
         {
             Add();
         }
         KeyTimer kt = KeyTimers[i];
         kt.Active = iterator.Current.GetAttribute("Active", "").ToLower() == "true";
         kt.Interval = Convert.ToInt32(iterator.Current.GetAttribute("Interval", ""));
         kt.Key = Convert.ToInt32(iterator.Current.GetAttribute("Key", ""));
         string startTime = iterator.Current.GetAttribute("StartTime", "");
         if (startTime != "")
         {
             DateTime minTime = Convert.ToDateTime("2012-01-01");
             kt.StartTime = Convert.ToDateTime(startTime);
             if (kt.StartTime < minTime)
             {
                 kt.StartTime = DateTime.Now;
             }
         }
         ++i;
     }
 }
コード例 #21
0
        private void WriteGenericTemplates(XPathNavigator type, SyntaxWriter writer, bool writeVariance)
        {
            XPathNodeIterator templates = type.Select(apiTemplatesExpression);

            if (templates.Count == 0) return;
            writer.WriteString("(");
            writer.WriteKeyword("Of");
            writer.WriteString(" ");
            while (templates.MoveNext())
            {
                XPathNavigator template = templates.Current;
                if (templates.CurrentPosition > 1) writer.WriteString(", ");
                if (writeVariance)
                {
                    bool contravariant = (bool)template.Evaluate(templateIsContravariantExpression);
                    bool covariant = (bool)template.Evaluate(templateIsCovariantExpression);

                    if (contravariant)
                    {
                        writer.WriteKeyword("In");
                        writer.WriteString(" ");
                    }
                    if (covariant)
                    {
                        writer.WriteKeyword("Out");
                        writer.WriteString(" ");
                    }
                }

                string name = template.GetAttribute("name", String.Empty);
                writer.WriteString(name);
            }
            writer.WriteString(")");

        }
        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodThatCreatesSwitch.SimpleClass.GenerateSwitch\"]/sequencepoints/entry");
            Assert.Equal(8, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("16", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x23")
                {
                    Assert.Equal("24", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("24", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
コード例 #23
0
        public static MaterialDefinition LoadFromXPathNavigator(XPathNavigator navigator)
        {
            if (navigator == null)
            {
                return null;
            }

            MaterialDefinition materialDefinition = new MaterialDefinition();

            //name
            materialDefinition.Name = navigator.GetAttribute("Name", string.Empty);
            materialDefinition.NameHash = Cryptography.JenkinsOneAtATime(materialDefinition.Name);

            //type
            materialDefinition.Type = navigator.GetAttribute("Type", string.Empty);
            materialDefinition.TypeHash = Cryptography.JenkinsOneAtATime(materialDefinition.Type);

            //draw styles
            XPathNodeIterator entries = navigator.Select("./Array[@Name='DrawStyles']/Object[@Class='DrawStyle']");

            while (entries.MoveNext())
            {
                DrawStyle drawStyle = DrawStyle.LoadFromXPathNavigator(entries.Current);

                if (drawStyle != null)
                {
                    materialDefinition.DrawStyles.Add(drawStyle);
                }
            }

            return materialDefinition;
        }
コード例 #24
0
ファイル: Episode.cs プロジェクト: fivesixty/StandaloneMB
        public Episode(FileInfo file, Season seasonparent)
            : base(file.Directory)
        {
            String xmlpath = file.Directory.FullName + "/metadata/" + Path.GetFileNameWithoutExtension(file.FullName) + ".xml";
            if (!File.Exists(xmlpath))
            {
                Valid = false;
                return;
            }
            EpisodeXml = new XPathDocument(xmlpath);
            EpisodeNav = EpisodeXml.CreateNavigator();
            EpisodeFile = file;

            _season = seasonparent;

            transX = 200;
            transY = 100;

            backdropImage = _season.backdropImage;

            XPathNodeIterator nodes = EpisodeNav.Select("//EpisodeID");
            nodes.MoveNext();
            folderImage = file.Directory.FullName + "/metadata/" + nodes.Current.Value + ".jpg";

            if (!File.Exists(folderImage))
                folderImage = "/Images/nothumb.jpg";
            title = this.asTitle();

            videoURL = EpisodeFile.FullName;

            LoadImage(folderImage);
        }
コード例 #25
0
        private static void AssertSequencePointsInFirstType(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"AssemblyWithTwoTypes.FirstClass.ReflectArgument\"]/sequencepoints/entry");
            Assert.Equal(2, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("16", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("16", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("21", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x1")
                {
                    Assert.Equal("17", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
コード例 #26
0
 internal static CpAllowedValueRange CreateAllowedValueRange(XPathNavigator allowedValueRangeElementNav, IXmlNamespaceResolver nsmgr)
 {
   XPathNodeIterator minIt = allowedValueRangeElementNav.Select("s:minimum", nsmgr);
   if (!minIt.MoveNext())
     return null;
   double min = Convert.ToDouble(ParserHelper.SelectText(minIt.Current, "text()", null));
   XPathNodeIterator maxIt = allowedValueRangeElementNav.Select("s:maximum", nsmgr);
   if (!maxIt.MoveNext())
     return null;
   double max = Convert.ToDouble(ParserHelper.SelectText(maxIt.Current, "text()", null));
   XPathNodeIterator stepIt = allowedValueRangeElementNav.Select("s:step", nsmgr);
   double? step = null;
   if (stepIt.MoveNext())
     step = Convert.ToDouble(ParserHelper.SelectText(stepIt.Current, "text()", null));
   return new CpAllowedValueRange(min, max, step);
 }
コード例 #27
0
ファイル: Measure.cs プロジェクト: wshanshan/DDD
		private void populateParametersDictionary(XPathNavigator parameters) {
			XPathNodeIterator iterator = parameters.Select("Parameters/Parameter");
			while (iterator.MoveNext()) {
				// TODO: populate the dictionary

			}
		}
コード例 #28
0
ファイル: SwitchComponent.cs プロジェクト: armin-bauer/SHFB
        //=====================================================================

        /// <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));
            }
        }
コード例 #29
0
ファイル: CloneComponent.cs プロジェクト: modulexcite/SHFB-1
        //=====================================================================

        /// <inheritdoc />
        /// <remarks>Multiple <c>branch</c> elements are specified as the configuration.  Each <c>branch</c>
        /// element can contain one or more <c>component</c> definitions that will be created and executed when
        /// this component is applied.  Each branch receives a clone of the document.  This may be useful for
        /// generating multiple help output formats in one build configuration.</remarks>
        public override void Initialize(XPathNavigator configuration)
        {
            XPathNodeIterator branchNodes = configuration.Select("branch");

            foreach(XPathNavigator branchNode in branchNodes)
                branches.Add(this.BuildAssembler.LoadComponents(branchNode));
        }
コード例 #30
0
        protected override void AssertSequencePoints(XPathNavigator navigator)
        {
            var entries = navigator.Select(
                "./symbols/methods/method[@name=\"MethodWithTryCatchFinally.SimpleClass.Divide\"]/sequencepoints/entry");
            Assert.Equal(12, entries.Count);

            int visitedCount = 0;

            foreach (XPathNavigator entry in entries)
            {
                if (entry.GetAttribute("il_offset", string.Empty) == "0x0")
                {
                    Assert.Equal("20", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("20", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("6", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("23", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
                else if (entry.GetAttribute("il_offset", string.Empty) == "0x2c")
                {
                    Assert.Equal("42", entry.GetAttribute("start_row", string.Empty));
                    Assert.Equal("42", entry.GetAttribute("end_row", string.Empty));
                    Assert.Equal("4", entry.GetAttribute("start_column", string.Empty));
                    Assert.Equal("17", entry.GetAttribute("end_column", string.Empty));
                    visitedCount++;
                }
            }

            Assert.Equal(2, visitedCount);
        }
コード例 #31
0
		private void ParseMappings(XPathNavigator navigator)
		{
			XPathNodeIterator xpni = navigator.Select(CfgXmlHelper.SessionFactoryMappingsExpression);
			while (xpni.MoveNext())
			{
				MappingConfiguration mc = new MappingConfiguration(xpni.Current);
				if (!mc.IsEmpty())
				{
					// Workaround add first an assembly&resource and then only the same assembly. 
					// the <mapping> of whole assembly is ignored (included only sigles resources)
					// The "ignore" log, is enough ?
					// Perhaps we can add some intelligence to remove single resource reference when a whole assembly is referenced
					//if (!mappings.Contains(mc))
					//{
					//  mappings.Add(mc);
					//}
					//else
					//{
					//  string logMessage = "Ignored mapping -> " + mc.ToString();
					//  if (log.IsDebugEnabled)
					//    log.Debug(logMessage);
					//  if (log.IsWarnEnabled)
					//    log.Warn(logMessage);
					//}

					// The control to prevent mappings duplication was removed since the engine do the right thing 
					// for this issue (simple is better)
					mappings.Add(mc);
				}
			}
		}
コード例 #32
0
        /// <summary>
        /// Override method that performs the actual property setting from a Navigator result.
        /// </summary>
        /// <param name="component"></param>
        /// <param name="data"></param>
        /// <param name="context"></param>
        protected override void DoBindComponent(object component, object data, PDFDataContext context)
        {
            System.Xml.XPath.XPathExpression expr = this.GetExpression(data, context);

            if (data is System.Xml.XPath.XPathNodeIterator)
            {
                data = ((System.Xml.XPath.XPathNodeIterator)data).Current;
            }

            System.Xml.XPath.XPathNavigator nav = (System.Xml.XPath.XPathNavigator)data;

            if (null == this.Converter)
            {
                var iterator = nav.Select(expr);

                if (this.Property.PropertyType == typeof(XPathNavigator))
                {
                    this.Property.SetValue(component, iterator.Current);
                }
                else
                {
                    this.Property.SetValue(component, iterator);
                }
            }
            else
            {
                System.Xml.XPath.XPathNodeIterator itter = nav.Select(expr);

                if (itter.CurrentPosition < 0)
                {
                    itter.MoveNext();
                }

                string value     = itter.Current.Value;
                object converted = this.Converter(value, this.Property.PropertyType, System.Globalization.CultureInfo.CurrentCulture);


                if (context.ShouldLogVerbose)
                {
                    context.TraceLog.Add(TraceLevel.Verbose, "Item Binding", "Setting property '" + this.Property.Name + "' with the XPath binding expression '" + expr.Expression + "' to value '" + ((null == value) ? "NULL" : value) + "'");
                }

                this.Property.SetValue(component, converted, null);
            }
        }
コード例 #33
0
    public XPathNodeIterator  ReturnDataXml(string tableXml, string condi)
    {
        // 'data xml dans un dropdowlistnormal
        string            val = "";
        XPathNodeIterator xmlNI;
        XPathDocument     xpathDoc = new XPathDocument(xmlpath + tableXml + ".xml");

        System.Xml.XPath.XPathNavigator xmlNav = xpathDoc.CreateNavigator();

        xmlNI = xmlNav.Select("//" + tableXml + "[" + condi + "]");
        if (xmlNI.Count > 0)
        {
            return(xmlNI);
        }
        return(null);
    }
コード例 #34
0
ファイル: GetLastOutputs.cs プロジェクト: leha-bot/Mono.XNA
        static bool BuildWasSuccessful(System.Xml.XPath.XPathNavigator navigator)
        {
            bool valueAsBoolean        = false;
            XPathNodeIterator iterator = navigator.Select("XnaContent/Asset/BuildSuccessful");

            iterator.MoveNext();
            try
            {
                valueAsBoolean = iterator.Current.ValueAsBoolean;
            }
            catch (FormatException)
            {
            }
            catch (InvalidCastException)
            {
            }
            return(valueAsBoolean);
        }
コード例 #35
0
    public string GetDataXmlValue(string tableXml, string condi, string SelectedField, string ValueIfNull = "")
    {
        // 'data xml dans un dropdowlistnormal
        string            val = "";
        XPathNodeIterator xmlNI;
        XPathDocument     xpathDoc = new XPathDocument(xmlpath + tableXml + ".xml");

        System.Xml.XPath.XPathNavigator xmlNav = xpathDoc.CreateNavigator();
        xmlNI = xmlNav.Select("//" + tableXml + "[" + condi + "]");
        if (xmlNI.Count == 0)
        {
            val = ValueIfNull;
        }
        else
        {
            while (xmlNI.MoveNext())
            {
                var bar = xmlNI.Current;
                if (bar.IsEmptyElement)
                {
                    val = ValueIfNull;
                }
                else
                {
                    val = bar.SelectSingleNode(SelectedField).Value;
                }
            }


            // 'cmb.Items.Add(New ListItem(.SelectSingleNode(libelle).Value, .SelectSingleNode(code).Value))
        }



        if (val == null)
        {
            val = "";
        }

        return(val);
    }
コード例 #36
0
        public virtual bool Matches(XPathExpression expr)
        {
            Expression e = ((CompiledExpression)expr).ExpressionNode;

            if (e is ExprRoot)
            {
                return(NodeType == XPathNodeType.Root);
            }

            NodeTest nt = e as NodeTest;

            if (nt != null)
            {
                switch (nt.Axis.Axis)
                {
                case Axes.Child:
                case Axes.Attribute:
                    break;

                default:
                    throw new XPathException("Only child and attribute pattern are allowed for a pattern.");
                }
                return(nt.Match(((CompiledExpression)expr).NamespaceManager, this));
            }
            if (e is ExprFilter)
            {
                do
                {
                    e = ((ExprFilter)e).LeftHandSide;
                } while (e is ExprFilter);

                if (e is NodeTest && !((NodeTest)e).Match(((CompiledExpression)expr).NamespaceManager, this))
                {
                    return(false);
                }
            }

            XPathResultType resultType = e.ReturnType;

            switch (resultType)
            {
            case XPathResultType.Any:
            case XPathResultType.NodeSet:
                break;

            default:
                return(false);
            }

            switch (e.EvaluatedNodeType)
            {
            case XPathNodeType.Attribute:
            case XPathNodeType.Namespace:
                if (NodeType != e.EvaluatedNodeType)
                {
                    return(false);
                }
                break;
            }

            XPathNodeIterator nodes;

            nodes = this.Select(expr);
            while (nodes.MoveNext())
            {
                if (IsSamePosition(nodes.Current))
                {
                    return(true);
                }
            }

            // ancestors might select this node.

            XPathNavigator navigator = Clone();

            while (navigator.MoveToParent())
            {
                nodes = navigator.Select(expr);

                while (nodes.MoveNext())
                {
                    if (IsSamePosition(nodes.Current))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #37
0
        private void ReadLegacyManifest(System.Xml.XPath.XPathNavigator manifestNav)
        {
            string fileName       = Null.NullString;
            string filePath       = Null.NullString;
            string sourceFileName = Null.NullString;
            string resourcetype   = Null.NullString;
            string moduleName     = Null.NullString;

            foreach (XPathNavigator fileNav in manifestNav.Select("Files/File"))
            {
                fileName       = Util.ReadAttribute(fileNav, "FileName".ToLowerInvariant());
                resourcetype   = Util.ReadAttribute(fileNav, "FileType");
                moduleName     = Util.ReadAttribute(fileNav, "ModuleName".ToLowerInvariant());
                sourceFileName = Path.Combine(resourcetype, Path.Combine(moduleName, fileName));
                string extendedExtension = "." + Language.Code.ToLowerInvariant() + ".resx";
                switch (resourcetype)
                {
                case "GlobalResource":
                    filePath = "App_GlobalResources";
                    _IsCore  = true;
                    break;

                case "ControlResource":
                    filePath = "Controls\\App_LocalResources";
                    break;

                case "AdminResource":
                    _IsCore = true;
                    switch (moduleName)
                    {
                    case "authentication":
                        filePath = "DesktopModules\\Admin\\Authentication\\App_LocalResources";
                        break;

                    case "controlpanel":
                        filePath = "Admin\\ControlPanel\\App_LocalResources";
                        break;

                    case "files":
                        filePath = "DesktopModules\\Admin\\FileManager\\App_LocalResources";
                        break;

                    case "host":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "authentication.ascx":
                            filePath = "";
                            break;

                        case "friendlyurls.ascx":
                            filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources";
                            break;

                        case "hostsettings.ascx":
                            filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources";
                            break;

                        case "requestfilters.ascx":
                            filePath = "DesktopModules\\Admin\\HostSettings\\App_LocalResources";
                            break;

                        case "solutions.ascx":
                            filePath = "DesktopModules\\Admin\\Solutions\\App_LocalResources";
                            break;
                        }
                        break;

                    case "lists":
                        filePath = "DesktopModules\\Admin\\Lists\\App_LocalResources";
                        break;

                    case "localization":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "languageeditor.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        case "languageeditorext.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        case "timezoneeditor.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        case "resourceverifier.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        default:
                            filePath = "";
                            break;
                        }
                        break;

                    case "log":
                        filePath = "DesktopModules\\Admin\\SiteLog\\App_LocalResources";
                        break;

                    case "logging":
                        filePath = "DesktopModules\\Admin\\LogViewer\\App_LocalResources";
                        break;

                    case "moduledefinitions":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "editmodulecontrol.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        case "importmoduledefinition.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        case "timezoneeditor.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        default:
                            filePath = "";
                            break;
                        }
                        break;

                    case "modules":
                        filePath = "Admin\\Modules\\App_LocalResources";
                        break;

                    case "packages":
                        filePath = "DesktopModules\\Admin\\Extensions\\App_LocalResources";
                        break;

                    case "portal":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "editportalalias.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "portalalias.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "portals.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "privacy.ascx":
                            filePath = "Admin\\Portal\\App_LocalResources";
                            break;

                        case "signup.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "sitesettings.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "sitewizard.ascx":
                            filePath = "DesktopModules\\Admin\\SiteWizard\\App_LocalResources";
                            break;

                        case "sql.ascx":
                            filePath = "DesktopModules\\Admin\\SQL\\App_LocalResources";
                            break;

                        case "systemmessages.ascx":
                            filePath = "";
                            break;

                        case "template.ascx":
                            filePath = "DesktopModules\\Admin\\Portals\\App_LocalResources";
                            break;

                        case "terms.ascx":
                            filePath = "Admin\\Portal\\App_LocalResources";
                            break;
                        }
                        break;

                    case "scheduling":
                        filePath = "DesktopModules\\Admin\\Scheduler\\App_LocalResources";
                        break;

                    case "search":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "inputsettings.ascx":
                            filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources";
                            break;

                        case "resultssettings.ascx":
                            filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources";
                            break;

                        case "searchadmin.ascx":
                            filePath = "DesktopModules\\Admin\\SearchAdmin\\App_LocalResources";
                            break;

                        case "searchinput.ascx":
                            filePath = "DesktopModules\\Admin\\SearchInput\\App_LocalResources";
                            break;

                        case "searchresults.ascx":
                            filePath = "DesktopModules\\Admin\\SearchResults\\App_LocalResources";
                            break;
                        }
                        break;

                    case "security":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "accessdenied.ascx":
                            filePath = "Admin\\Security\\App_LocalResources";
                            break;

                        case "authenticationsettings.ascx":
                            filePath = "";
                            break;

                        case "editgroups.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "editroles.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "register.ascx":
                            filePath = "";
                            break;

                        case "roles.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "securityroles.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "sendpassword.ascx":
                            filePath = "Admin\\Security\\App_LocalResources";
                            break;

                        case "signin.ascx":
                            filePath = "";
                            break;
                        }
                        break;

                    case "skins":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "attributes.ascx":
                            filePath = "DesktopModules\\Admin\\SkinDesigner\\App_LocalResources";
                            break;

                        case "editskins.ascx":
                            filePath = "DesktopModules\\Admin\\Extensions\\Editors\\App_LocalResources";
                            break;

                        default:
                            filePath = "Admin\\Skins\\App_LocalResources";
                            break;
                        }
                        break;

                    case "syndication":
                        filePath = "DesktopModules\\Admin\\FeedExplorer\\App_LocalResources";
                        break;

                    case "tabs":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "export.ascx":
                            filePath = "Admin\\Tabs\\App_LocalResources";
                            break;

                        case "import.ascx":
                            filePath = "Admin\\Tabs\\App_LocalResources";
                            break;

                        case "managetabs.ascx":
                            filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources";
                            break;

                        case "recyclebin.ascx":
                            filePath = "DesktopModules\\Admin\\RecycleBin\\App_LocalResources";
                            break;

                        case "tabs.ascx":
                            filePath = "DesktopModules\\Admin\\Tabs\\App_LocalResources";
                            break;
                        }
                        break;

                    case "users":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "bulkemail.ascx":
                            filePath = "DesktopModules\\Admin\\Newsletters\\App_LocalResources";
                            fileName = "Newsletter.ascx" + extendedExtension;
                            break;

                        case "editprofiledefinition.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "manageusers.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "memberservices.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "membership.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "password.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "profile.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "profiledefinitions.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "user.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "users.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "usersettings.ascx":
                            filePath = "DesktopModules\\Admin\\Security\\App_LocalResources";
                            break;

                        case "viewprofile.ascx":
                            filePath = "Admin\\Users\\App_LocalResources";
                            break;
                        }
                        break;

                    case "vendors":
                        switch (fileName.Replace(extendedExtension, ""))
                        {
                        case "adsense.ascx":
                            filePath = "";
                            break;

                        case "editadsense.ascx":
                            filePath = "";
                            break;

                        case "affiliates.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;

                        case "banneroptions.ascx":
                            filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources";
                            break;

                        case "banners.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;

                        case "displaybanners.ascx":
                            filePath = "DesktopModules\\Admin\\Banners\\App_LocalResources";
                            break;

                        case "editaffiliate.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;

                        case "editbanner.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;

                        case "editvendors.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;

                        case "vendors.ascx":
                            filePath = "DesktopModules\\Admin\\Vendors\\App_LocalResources";
                            break;
                        }
                        break;
                    }
                    break;

                case "LocalResource":
                    filePath = Path.Combine("DesktopModules", Path.Combine(moduleName, "App_LocalResources"));
                    if (!_IsCore && _LanguagePack == null)
                    {
                        Locale locale = Localization.Localization.GetLocale(_Language.Code);
                        if (locale == null)
                        {
                            LegacyError = "CoreLanguageError";
                        }
                        else
                        {
                            foreach (KeyValuePair <int, DesktopModuleInfo> kvp in DesktopModuleController.GetDesktopModules(Null.NullInteger))
                            {
                                if (kvp.Value.FolderName.ToLowerInvariant() == moduleName)
                                {
                                    PackageInfo dependentPackage = PackageController.GetPackage(kvp.Value.PackageID);
                                    Package.Name                    += "_" + dependentPackage.Name;
                                    Package.FriendlyName            += " " + dependentPackage.FriendlyName;
                                    _LanguagePack                    = new LanguagePackInfo();
                                    _LanguagePack.DependentPackageID = dependentPackage.PackageID;
                                    _LanguagePack.LanguageID         = locale.LanguageID;
                                    break;
                                }
                            }
                            if (_LanguagePack == null)
                            {
                                LegacyError = "DependencyError";
                            }
                        }
                    }
                    break;

                case "ProviderResource":
                    filePath = Path.Combine("Providers", Path.Combine(moduleName, "App_LocalResources"));
                    break;

                case "InstallResource":
                    filePath = "Install\\App_LocalResources";
                    break;
                }
                if (!string.IsNullOrEmpty(filePath))
                {
                    AddFile(Path.Combine(filePath, fileName), sourceFileName);
                }
            }
        }
コード例 #38
0
        static void SendFiles(string _fileName, string _dir)
        {
            TextWriter tw = null;

            var dic = new Dictionary <string, Findings>();

            if (optumFindings == null)
            {
                optumFindings = new List <Findings>();
            }
            else
            {
                optumFindings.Clear();
            }


            List <string> thisRun     = new List <string>();
            int           loop        = 0;
            int           lineCounter = 0;

            try
            {
                log.LogInformation(String.Format("In SendFiles {0} {1}", _fileName, _dir));
                string     user         = "******";
                string     password     = "******";
                string     claimsDotXml = _fileName;
                WebRequest req          = WebRequest.Create("https://realtimeecontent.com/ws/claims5x");

                req.Method      = "POST";
                req.ContentType = "application/xml";
                req.Credentials = new NetworkCredential(user, password);
                FileStream fs       = new FileStream(claimsDotXml, FileMode.Open);
                string     outFile  = String.Format(@"{0}\OUT\{1}.out", _dir, Path.GetFileName(_fileName));
                string     outFile2 = String.Format(@"{0}\OUT\{1}2.out", _dir, Path.GetFileName(_fileName));

                if (File.Exists(outFile))
                {
                    File.Delete(outFile);
                }

                log.LogInformation(String.Format("Creating File {0} ", outFile));
                tw = File.CreateText(outFile);


                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                using (Stream reqStream = req.GetRequestStream())
                {
                    byte[] buffer    = new byte[1024];
                    int    bytesRead = 0;
                    while ((bytesRead = fs.Read(buffer, 0, buffer.Length)) != 0)
                    {
                        reqStream.Write(buffer, 0, bytesRead);
                    }
                    fs.Close();
                }

                System.Net.HttpWebResponse resp = req.GetResponse() as System.Net.HttpWebResponse;
                if (resp.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    System.Xml.XPath.XPathDocument  xmlDoc = new System.Xml.XPath.XPathDocument(resp.GetResponseStream());
                    System.Xml.XPath.XPathNavigator nav    = xmlDoc.CreateNavigator();
                    //Console.WriteLine("Claim A5 had {0} Edits.", nav.Evaluate("count(/claim-responses/claim-response[@claim-id='43']/edit)"));
                    //Console.WriteLine(nav.Evaluate("/claim-responses/claim-response/edit"));
                    lineCounter++;
                    loop = 1;
                    XPathNodeIterator xPathIterator = nav.Select("/claim-responses//claim-response");
                    int    errLine = 0;
                    int    lastConflictFound = 0, iClaimLine = 0;
                    string lastClaim = "";
                    foreach (XPathNavigator claimResponse in xPathIterator)
                    {
                        XPathNavigator onav = claimResponse.SelectSingleNode("@claim-id");
                        string         id   = onav == null ? string.Empty : onav.Value;

                        try {
                            thisRun.Add(id);
                        }catch (Exception mex)
                        {
                            log.LogError(mex.Message);
                        }

                        if (id.CompareTo("20170309T33K00018") == 0)
                        {
                            errLine = 0;
                        }

                        XPathNodeIterator ixPathIterator = claimResponse.Select("edit");
                        bool hasEdits  = false;
                        int  noOfEdits = 0;
                        foreach (XPathNavigator editLines in ixPathIterator)
                        {
                            hasEdits = true;
                            noOfEdits++;
                            onav = editLines.SelectSingleNode("@line");
                            string claimLine = onav == null ? string.Empty : onav.Value;
                            string key       = id.Trim() + "|" + claimLine.Trim();

                            ClaimLinesIndex _cli;
                            try
                            {
                                iClaimLine = int.Parse(claimLine);
                            }
                            catch (Exception ex)
                            {
                                iClaimLine = 0;
                            }
                            if (iClaimLine > lastConflictFound)
                            {
                                string myId = "";
                                lastConflictFound = iClaimLine;
                            }

                            XPathNavigator inav        = editLines.SelectSingleNode("description");
                            string         description = editLines == null ? string.Empty : inav.Value;

                            //if (description.Contains("[Pattern 10372]"))
                            //    hasEdits = false;

                            //inav = editLines.SelectSingleNode("edit-conflict");
                            string editConflict = ""; // editLines == null ? string.Empty : inav.Value;

                            inav = editLines.SelectSingleNode("edit-type");
                            string editType = editLines == null ? string.Empty : inav.Value;

                            inav = editLines.SelectSingleNode("mnemonic");
                            string mnemonic = editLines == null ? string.Empty : inav.Value;


                            Findings opFind = new Findings();
                            opFind.id          = id;
                            opFind.lineNo      = claimLine;
                            opFind.editType    = editType;
                            opFind.mnemonic    = mnemonic;
                            opFind.editConflit = editConflict;
                            opFind.description = description;
                            optumFindings.Add(opFind);


                            if (!claimLinesList.ContainsKey(key))
                            {
                                log.LogError(String.Format("The claim does not contain {0}", key));
                                _cli            = new ClaimLinesIndex();
                                _cli.claim      = id;
                                _cli.hasDU      = true;
                                _cli.lineNo     = "-99";
                                _cli.claimIndex = "-99";
                            }
                            else
                            {
                                _cli = claimLinesList[key];
                            }
                            if (!_cli.hasDU)
                            {
                                if (!description.Contains("50.0%")) // Ignore Optum
                                {
                                    Findings findings = new Findings();
                                    findings.id          = id;
                                    findings.claimIndex  = _cli.claimIndex;
                                    findings.editType    = editType;
                                    findings.mnemonic    = mnemonic;
                                    findings.editConflit = editConflict;
                                    findings.description = description;
                                    try {
                                        dic.Add(String.Format("{0}{1}{2}", id, _cli.claimIndex, (++errLine).ToString()), findings);
                                    }catch (Exception mex)
                                    {
                                        log.LogError(mex.Message);
                                    }
                                }
                                else
                                {
                                    if (noOfEdits == 1) // this is the only edit for the claim and it's a wrong one mMP
                                    {
                                        hasEdits = false;
                                    }
                                    noOfEdits--;
                                }
                            }
                        }
                        if (hasEdits == false)
                        { // claim does not have any edits
                          //string percentage = "";
                          //ClaimLinesIndex _cli;
                          //int found = 0;

                            //if (found == 0)
                            //{
                            if (IsCleanClaim(id, claimLinesList))
                            {
                                Findings findings = new Findings();
                                findings.id          = id;
                                findings.claimIndex  = "0";
                                findings.editType    = "";
                                findings.mnemonic    = "";
                                findings.editConflit = "";
                                findings.description = "";
                                try {
                                    dic.Add(String.Format("{0}{1}{2}", id, findings.claimIndex, (++errLine).ToString()), findings);
                                }catch (Exception mex)
                                {
                                    log.LogError(mex.Message);
                                }
                            }

                            //tw.WriteLine("************ Claim {0} is clean ********", id);
                            //}
                        }
                    }
                    //FinishTheEdits(lastConflictFound - 1, lastClaim, claimLinesList, dic, errLine);
                }
                ReviewClaimLineList(tw);
                optumFindings.Clear();
                dic.Clear();
                dic = null;
                tw.Close();
            }
            catch (Exception ex)
            {
                log.LogError(String.Format("Sending Files {0}", ex.Message));
            }
            finally
            {
                //claimLinesList.Clear();
                thisRun.Clear();
            }
        }
コード例 #39
-3
ファイル: EditCand.cs プロジェクト: ayeec/evote
        private void EditCand_Load(object sender, EventArgs e)
        {
            doc = new XPathDocument(FILE_NAME);
            nav = doc.CreateNavigator();

            // Compile a standard XPath expression

            expr = nav.Compile("/config/voto/@puesto");
            iterator = nav.Select(expr);

            // Iterate on the node set
            comboBox1.Items.Clear();
            try
            {
                while (iterator.MoveNext())
                {
                    XPathNavigator nav2 = iterator.Current.Clone();
                    comboBox1.Items.Add(nav2.Value);
                    comboBox1.SelectedIndex = 0;

                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }


            //save old title 
            oldTitle = comboBox1.Text;

        }