/// <summary> /// Initializes a new instance of the <see cref="TournamentInfo" /> class. /// </summary> /// <param name="cacheItem">The cache item</param> /// <param name="categorySummary">The category summary</param> /// <param name="currentSeasonInfo">The full current season info</param> public TournamentInfo(TournamentInfoBasicCI cacheItem, ICategorySummary categorySummary, ICurrentSeasonInfo currentSeasonInfo) : base(cacheItem.Id, cacheItem.Name as IReadOnlyDictionary <CultureInfo, string>) { Category = categorySummary; CurrentSeason = currentSeasonInfo; }
private void MatchFile(string outputRootDir, ICategorySummary category, IRuleSummary ruleSummary) { XmlDocument doc = new XmlDocument(); XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(declaration); var pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + Ids.XSLT_DIR + "/" + Ids.MATCHES_XSLT_FILE + "\""); doc.AppendChild(pi); XmlNode matches = doc.CreateNode(XmlNodeType.Element, "Matches", null); XmlNode summaryNode = doc.CreateNode(XmlNodeType.Element, "Summary", null); XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode ruleNameNode = doc.CreateNode(XmlNodeType.Element, "Name", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode expressionNode = doc.CreateNode(XmlNodeType.Element, "Expression", null); summaryNode.AppendChild(expressionNode); summaryNode.AppendChild(ruleNameNode); summaryNode.AppendChild(descriptionNode); summaryNode.AppendChild(countNode); matches.AppendChild(summaryNode); doc.AppendChild(matches); // Summary.Name node... XmlCDataSection cdataRuleNameNode = doc.CreateCDataSection(ruleSummary.Name); ruleNameNode.AppendChild(cdataRuleNameNode); // Summary.Description node... XmlCDataSection cdataDescriptionNode = doc.CreateCDataSection(ruleSummary.Description); descriptionNode.AppendChild(cdataDescriptionNode); // Summary.Expression node... XmlCDataSection cdataExpressionNode = doc.CreateCDataSection(ruleSummary.Expression); expressionNode.AppendChild(cdataExpressionNode); // Summary.Count node... countNode.InnerText = ruleSummary.Matches.Count.ToString(); //int matchId = 1; foreach (IMatch match in ruleSummary.Matches) { //MatchXml(doc, matches, matchId++, match); } doc.Save(CreateFullPathForMatchFile(outputRootDir, category.Name, ruleSummary.Name)); }
//private void TocCategoryContent(string outputRootDir, XmlDocument doc, XmlNode node) //{ // #region Validate arguments // if (doc == null) throw new ArgumentNullException("doc"); // if (node == null) throw new ArgumentNullException("node"); // #endregion // ProxyHome.Instance.ConfigurationComponentProxy.Projects(); // List<string> retrieveCategories = MatchHome.RetrieveCategories(); // retrieveCategories.Sort(); // int counterId = 1; // foreach (string category in retrieveCategories) // { // // Generate 'Id' - the id is needed for the javascript to work properly in the resulting html output file. // // Category name = 'category' from the surrounding 'foreach'. :-) // // Count - how many matches was found in the current category? // // Description - Description is part of each Match, so get the description from the first element in the categorylist. // // Filename - the filename must be constructed for each category. // ICategorySummary categorySummary = MatchHome.RetriveCategorySummary(category); // categorySummary.Id = counterId++; // // Create the link for the current category's rules file... // categorySummary.LinkToCategoryXmlFile = CreateNameForRulesFile(category); // // Create the xml for the current category... // XmlNode categoryNode = doc.CreateNode(XmlNodeType.Element, "Category", null); // TocCategoryXml(doc, categoryNode, categorySummary); // // For each category a set of rules can be defined - these rules will have to have their // // own sub-toc file, so let's go ahead and create that file. // SubTocRulesContent(outputRootDir, categorySummary); // node.AppendChild(categoryNode); // } //} private void TocCategoryXml(XmlDocument doc, XmlNode categoryNode, ICategorySummary categorySummary) { // The following is an example of how a category is represented in the resulting xml file: // ======================================================================================= // // <Category Id="2" Name="Test name 2"> // <Count>123</Count> // <Description>This is a test description...</Description> // <Filename>XmlReport.xml</Filename> // </Category> // // ======================================================================================= XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode filenameNode = doc.CreateNode(XmlNodeType.Element, "Filename", null); XmlNode severityNode = doc.CreateNode(XmlNodeType.Element, "Severity", null); // Category node... XmlAttribute idAttrib = doc.CreateAttribute("Id"); XmlAttribute nameAttrib = doc.CreateAttribute("Name"); idAttrib.Value = categorySummary.Id.ToString(); nameAttrib.Value = categorySummary.Name; categoryNode.Attributes.Append(idAttrib); categoryNode.Attributes.Append(nameAttrib); // Count node... countNode.InnerText = categorySummary.Count.ToString(); categoryNode.AppendChild(countNode); // Description node... descriptionNode.InnerText = categorySummary.Description; categoryNode.AppendChild(descriptionNode); // Filename node... filenameNode.InnerText = categorySummary.LinkToCategoryXmlFile; categoryNode.AppendChild(filenameNode); // Severity node... XmlAttribute severityValueAttrib = doc.CreateAttribute("Value"); severityValueAttrib.Value = (int)categorySummary.Severity + ""; severityNode.Attributes.Append(severityValueAttrib); severityNode.InnerText = categorySummary.Severity.ToString(); categoryNode.AppendChild(severityNode); }
//private void TocCategoryContent(string outputRootDir, XmlDocument doc, XmlNode node) //{ // #region Validate arguments // if (doc == null) throw new ArgumentNullException("doc"); // if (node == null) throw new ArgumentNullException("node"); // #endregion // ProxyHome.Instance.ConfigurationComponentProxy.Projects(); // List<string> retrieveCategories = MatchHome.RetrieveCategories(); // retrieveCategories.Sort(); // int counterId = 1; // foreach (string category in retrieveCategories) // { // // Generate 'Id' - the id is needed for the javascript to work properly in the resulting html output file. // // Category name = 'category' from the surrounding 'foreach'. :-) // // Count - how many matches was found in the current category? // // Description - Description is part of each Match, so get the description from the first element in the categorylist. // // Filename - the filename must be constructed for each category. // ICategorySummary categorySummary = MatchHome.RetriveCategorySummary(category); // categorySummary.Id = counterId++; // // Create the link for the current category's rules file... // categorySummary.LinkToCategoryXmlFile = CreateNameForRulesFile(category); // // Create the xml for the current category... // XmlNode categoryNode = doc.CreateNode(XmlNodeType.Element, "Category", null); // TocCategoryXml(doc, categoryNode, categorySummary); // // For each category a set of rules can be defined - these rules will have to have their // // own sub-toc file, so let's go ahead and create that file. // SubTocRulesContent(outputRootDir, categorySummary); // node.AppendChild(categoryNode); // } //} private void TocCategoryXml(XmlDocument doc, XmlNode categoryNode, ICategorySummary categorySummary) { // The following is an example of how a category is represented in the resulting xml file: // ======================================================================================= // // <Category Id="2" Name="Test name 2"> // <Count>123</Count> // <Description>This is a test description...</Description> // <Filename>XmlReport.xml</Filename> // </Category> // // ======================================================================================= XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode filenameNode = doc.CreateNode(XmlNodeType.Element, "Filename", null); XmlNode severityNode = doc.CreateNode(XmlNodeType.Element, "Severity", null); // Category node... XmlAttribute idAttrib = doc.CreateAttribute("Id"); XmlAttribute nameAttrib = doc.CreateAttribute("Name"); idAttrib.Value = categorySummary.Id.ToString(); nameAttrib.Value = categorySummary.Name; categoryNode.Attributes.Append(idAttrib); categoryNode.Attributes.Append(nameAttrib); // Count node... countNode.InnerText = categorySummary.Count.ToString(); categoryNode.AppendChild(countNode); // Description node... descriptionNode.InnerText = categorySummary.Description; categoryNode.AppendChild(descriptionNode); // Filename node... filenameNode.InnerText = categorySummary.LinkToCategoryXmlFile; categoryNode.AppendChild(filenameNode); // Severity node... XmlAttribute severityValueAttrib = doc.CreateAttribute("Value"); severityValueAttrib.Value = (int)categorySummary.Severity + ""; severityNode.Attributes.Append(severityValueAttrib); severityNode.InnerText = categorySummary.Severity.ToString(); categoryNode.AppendChild(severityNode); }
//private void SubTocRulesContent(string outputRootDir, ICategorySummary categorySummary) //{ // XmlDocument doc = new XmlDocument(); // XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); // doc.AppendChild(declaration); // var pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + Ids.XSLT_DIR + "/" + Ids.SUB_TOC_XSLT_FILE + "\""); // doc.AppendChild(pi); // XmlNode rules = doc.CreateNode(XmlNodeType.Element, "Rules", null); // // Creating a list to hold all the 'ruleSummary summaries'... // Dictionary<string, IRuleSummary> ruleSummaries = new Dictionary<string, IRuleSummary>(); // // Extract all the matches related to the current category... // List<IMatch> matches = MatchHome.MatchesByCategory(categorySummary.Name); // // Extract all the rules from the matches in the current category... // int ruleCounter = 0; // foreach (IMatch match in matches) // { // if (!ruleSummaries.ContainsKey(match.RegExp.Name)) // { // IRuleSummary ruleSummary = ProxyHome.Instance.EngineComponentProxy.InstatiateRuleSummary(++ruleCounter, // match.RegExp.Enabled, // 1, // match.RegExp.Name, // match.RegExp.Description, // match.RegExp.Expression, // match.Severity, // CreateNameForMatchFile(categorySummary.Name, match.RegExp.Name)); // ruleSummary.Matches.Add(match); // // First ruleSummary of this specific ruleSummary. // ruleSummaries.Add(ruleSummary.Name, ruleSummary); // } // else // { // // Second or n'th encounter of this specific ruleSummary. // ruleSummaries[match.RegExp.Name].Count++; // ruleSummaries[match.RegExp.Name].Matches.Add(match); // } // } // // Now that have extracted all the 'ruleSummary summaries' let's go ahead and create the // // ruleSummary xml nodes... // foreach (KeyValuePair<string, IRuleSummary> pair in ruleSummaries) // { // RuleXml(doc, rules, outputRootDir, categorySummary, pair.Value); // MatchFile(outputRootDir, categorySummary, pair.Value); // } // doc.AppendChild(rules); // doc.Save(CreateFullPathForRulesFile(outputRootDir, categorySummary.Name)); //} private void RuleXml(XmlDocument doc, XmlNode node, string outputRootDir, ICategorySummary category, IRuleSummary ruleSummary) { // The following is an example of how a category is represented in the resulting report xml file: // ============================================================================================== // // <Rule Id="1"> // <Count>123</Count> // <Enabled>true</Enabled> // <Name>Finds classes</Name> // <Description>Finds all the class definitions.</Description> // <Severity>Critical</Severity> // <Expression>\s*public\s*class\s*</Expression> // <Link>SomeFile.xml</Link> // </Rule> // // ============================================================================================== XmlNode ruleNode = doc.CreateNode(XmlNodeType.Element, "Rule", null); XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode enabledNode = doc.CreateNode(XmlNodeType.Element, "Enabled", null); XmlNode nameNode = doc.CreateNode(XmlNodeType.Element, "Name", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode severityNode = doc.CreateNode(XmlNodeType.Element, "Severity", null); XmlNode expressionNode = doc.CreateNode(XmlNodeType.Element, "Expression", null); XmlNode linkNode = doc.CreateNode(XmlNodeType.Element, "Link", null); // Rule node... XmlAttribute idAttrib = doc.CreateAttribute("Id"); idAttrib.Value = ruleSummary.Id.ToString(); ruleNode.Attributes.Append(idAttrib); // Count node... countNode.InnerText = ruleSummary.Count.ToString(); // Enabled node... enabledNode.InnerText = ruleSummary.Enabled.ToString(); // Name node... XmlCDataSection cdataNameNode = doc.CreateCDataSection(ruleSummary.Name); nameNode.AppendChild(cdataNameNode); // Description node... XmlCDataSection cdataDescriptionNode = doc.CreateCDataSection(ruleSummary.Description); descriptionNode.AppendChild(cdataDescriptionNode); // Expression node... XmlCDataSection cdataExpression = doc.CreateCDataSection(ruleSummary.Expression); expressionNode.AppendChild(cdataExpression); // Severity node... severityNode.InnerText = ruleSummary.Severity.ToString(); // Link node... linkNode.InnerText = CreateNameForMatchFile(category.Name, ruleSummary.Name); // Add all nodes to the 'node' given in the arguments. ruleNode.AppendChild(countNode); ruleNode.AppendChild(enabledNode); ruleNode.AppendChild(nameNode); ruleNode.AppendChild(descriptionNode); ruleNode.AppendChild(severityNode); ruleNode.AppendChild(expressionNode); ruleNode.AppendChild(linkNode); node.AppendChild(ruleNode); // Finally let's add the current rule node to the overall container of rule nodes. // Later in the process all the rule nodes will be persisted to a AllRules.xml file. ContainerOfRuleNodes.Add(ruleNode); }
private void MatchFile(string outputRootDir, ICategorySummary category, IRuleSummary ruleSummary) { XmlDocument doc = new XmlDocument(); XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); doc.AppendChild(declaration); var pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + Ids.XSLT_DIR + "/" + Ids.MATCHES_XSLT_FILE + "\""); doc.AppendChild(pi); XmlNode matches = doc.CreateNode(XmlNodeType.Element, "Matches", null); XmlNode summaryNode = doc.CreateNode(XmlNodeType.Element, "Summary", null); XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode ruleNameNode = doc.CreateNode(XmlNodeType.Element, "Name", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode expressionNode = doc.CreateNode(XmlNodeType.Element, "Expression", null); summaryNode.AppendChild(expressionNode); summaryNode.AppendChild(ruleNameNode); summaryNode.AppendChild(descriptionNode); summaryNode.AppendChild(countNode); matches.AppendChild(summaryNode); doc.AppendChild(matches); // Summary.Name node... XmlCDataSection cdataRuleNameNode = doc.CreateCDataSection(ruleSummary.Name); ruleNameNode.AppendChild(cdataRuleNameNode); // Summary.Description node... XmlCDataSection cdataDescriptionNode = doc.CreateCDataSection(ruleSummary.Description); descriptionNode.AppendChild(cdataDescriptionNode); // Summary.Expression node... XmlCDataSection cdataExpressionNode = doc.CreateCDataSection(ruleSummary.Expression); expressionNode.AppendChild(cdataExpressionNode); // Summary.Count node... countNode.InnerText = ruleSummary.Matches.Count.ToString(); //int matchId = 1; foreach (IMatch match in ruleSummary.Matches) { //MatchXml(doc, matches, matchId++, match); } doc.Save(CreateFullPathForMatchFile(outputRootDir, category.Name, ruleSummary.Name)); }
//private void SubTocRulesContent(string outputRootDir, ICategorySummary categorySummary) //{ // XmlDocument doc = new XmlDocument(); // XmlDeclaration declaration = doc.CreateXmlDeclaration("1.0", "UTF-8", null); // doc.AppendChild(declaration); // var pi = doc.CreateProcessingInstruction("xml-stylesheet", "type=\"text/xsl\" href=\"" + Ids.XSLT_DIR + "/" + Ids.SUB_TOC_XSLT_FILE + "\""); // doc.AppendChild(pi); // XmlNode rules = doc.CreateNode(XmlNodeType.Element, "Rules", null); // // Creating a list to hold all the 'ruleSummary summaries'... // Dictionary<string, IRuleSummary> ruleSummaries = new Dictionary<string, IRuleSummary>(); // // Extract all the matches related to the current category... // List<IMatch> matches = MatchHome.MatchesByCategory(categorySummary.Name); // // Extract all the rules from the matches in the current category... // int ruleCounter = 0; // foreach (IMatch match in matches) // { // if (!ruleSummaries.ContainsKey(match.RegExp.Name)) // { // IRuleSummary ruleSummary = ProxyHome.Instance.EngineComponentProxy.InstatiateRuleSummary(++ruleCounter, // match.RegExp.Enabled, // 1, // match.RegExp.Name, // match.RegExp.Description, // match.RegExp.Expression, // match.Severity, // CreateNameForMatchFile(categorySummary.Name, match.RegExp.Name)); // ruleSummary.Matches.Add(match); // // First ruleSummary of this specific ruleSummary. // ruleSummaries.Add(ruleSummary.Name, ruleSummary); // } // else // { // // Second or n'th encounter of this specific ruleSummary. // ruleSummaries[match.RegExp.Name].Count++; // ruleSummaries[match.RegExp.Name].Matches.Add(match); // } // } // // Now that have extracted all the 'ruleSummary summaries' let's go ahead and create the // // ruleSummary xml nodes... // foreach (KeyValuePair<string, IRuleSummary> pair in ruleSummaries) // { // RuleXml(doc, rules, outputRootDir, categorySummary, pair.Value); // MatchFile(outputRootDir, categorySummary, pair.Value); // } // doc.AppendChild(rules); // doc.Save(CreateFullPathForRulesFile(outputRootDir, categorySummary.Name)); //} private void RuleXml(XmlDocument doc, XmlNode node, string outputRootDir, ICategorySummary category, IRuleSummary ruleSummary) { // The following is an example of how a category is represented in the resulting report xml file: // ============================================================================================== // // <Rule Id="1"> // <Count>123</Count> // <Enabled>true</Enabled> // <Name>Finds classes</Name> // <Description>Finds all the class definitions.</Description> // <Severity>Critical</Severity> // <Expression>\s*public\s*class\s*</Expression> // <Link>SomeFile.xml</Link> // </Rule> // // ============================================================================================== XmlNode ruleNode = doc.CreateNode(XmlNodeType.Element, "Rule", null); XmlNode countNode = doc.CreateNode(XmlNodeType.Element, "Count", null); XmlNode enabledNode = doc.CreateNode(XmlNodeType.Element, "Enabled", null); XmlNode nameNode = doc.CreateNode(XmlNodeType.Element, "Name", null); XmlNode descriptionNode = doc.CreateNode(XmlNodeType.Element, "Description", null); XmlNode severityNode = doc.CreateNode(XmlNodeType.Element, "Severity", null); XmlNode expressionNode = doc.CreateNode(XmlNodeType.Element, "Expression", null); XmlNode linkNode = doc.CreateNode(XmlNodeType.Element, "Link", null); // Rule node... XmlAttribute idAttrib = doc.CreateAttribute("Id"); idAttrib.Value = ruleSummary.Id.ToString(); ruleNode.Attributes.Append(idAttrib); // Count node... countNode.InnerText = ruleSummary.Count.ToString(); // Enabled node... enabledNode.InnerText = ruleSummary.Enabled.ToString(); // Name node... XmlCDataSection cdataNameNode = doc.CreateCDataSection(ruleSummary.Name); nameNode.AppendChild(cdataNameNode); // Description node... XmlCDataSection cdataDescriptionNode = doc.CreateCDataSection(ruleSummary.Description); descriptionNode.AppendChild(cdataDescriptionNode); // Expression node... XmlCDataSection cdataExpression = doc.CreateCDataSection(ruleSummary.Expression); expressionNode.AppendChild(cdataExpression); // Severity node... severityNode.InnerText = ruleSummary.Severity.ToString(); // Link node... linkNode.InnerText = CreateNameForMatchFile(category.Name, ruleSummary.Name); // Add all nodes to the 'node' given in the arguments. ruleNode.AppendChild(countNode); ruleNode.AppendChild(enabledNode); ruleNode.AppendChild(nameNode); ruleNode.AppendChild(descriptionNode); ruleNode.AppendChild(severityNode); ruleNode.AppendChild(expressionNode); ruleNode.AppendChild(linkNode); node.AppendChild(ruleNode); // Finally let's add the current rule node to the overall container of rule nodes. // Later in the process all the rule nodes will be persisted to a AllRules.xml file. ContainerOfRuleNodes.Add(ruleNode); }