private void LoadEntityNodes(SafeXmlDocument doc, Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> reportPropertyCmdletParamMapping) { using (XmlNodeList xmlNodeList = doc.SelectNodes("/Configuration/Reports/Report")) { HashSet <string> hashSet = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; ReportingSchema.CheckCondition(!string.IsNullOrWhiteSpace(xmlNode.Attributes["Name"].Value) && !string.IsNullOrWhiteSpace(xmlNode.Attributes["Snapin"].Value) && !string.IsNullOrWhiteSpace(xmlNode.Attributes["Cmdlet"].Value), string.Format("Attributes {0}, {1}, {2} of entity should not be empty.", "Name", "Cmdlet", "Snapin")); hashSet.Add(xmlNode.Attributes["Snapin"].Value.Trim()); } using (IPSCommandResolver ipscommandResolver = DependencyFactory.CreatePSCommandResolver(hashSet)) { foreach (object obj2 in xmlNodeList) { XmlNode xmlNode2 = (XmlNode)obj2; string text = xmlNode2.Attributes["Name"].Value.Trim(); string text2 = xmlNode2.Attributes["Cmdlet"].Value.Trim(); string snapinName = xmlNode2.Attributes["Snapin"].Value.Trim(); ReportingSchema.CheckCondition(!this.entities.ContainsKey(text), "Duplicate entity in the config file"); Dictionary <string, string> dictionary = null; using (XmlNodeList xmlNodeList2 = xmlNode2.SelectNodes("CmdletParameters/CmdletParameter")) { if (xmlNodeList2.Count > 0) { dictionary = new Dictionary <string, string>(xmlNodeList2.Count); foreach (object obj3 in xmlNodeList2) { XmlNode xmlNode3 = (XmlNode)obj3; ReportingSchema.CheckCondition(!string.IsNullOrWhiteSpace(xmlNode3.Attributes["Name"].Value) && !string.IsNullOrWhiteSpace(xmlNode3.Attributes["Value"].Value), "cmdlet parameter name and value should not be empty."); string key = xmlNode3.Attributes["Name"].Value.Trim(); string value = xmlNode3.Attributes["Value"].Value.Trim(); dictionary.Add(key, value); } } } Dictionary <string, List <string> > dictionary2 = null; if (reportPropertyCmdletParamMapping.ContainsKey(text2)) { dictionary2 = new Dictionary <string, List <string> >(reportPropertyCmdletParamMapping[text2].Length); foreach (ReportingSchema.ReportPropertyCmdletParamMapping reportPropertyCmdletParamMapping2 in reportPropertyCmdletParamMapping[text2]) { if (!dictionary2.ContainsKey(reportPropertyCmdletParamMapping2.ReportObjectProperty)) { dictionary2.Add(reportPropertyCmdletParamMapping2.ReportObjectProperty, new List <string>()); } dictionary2[reportPropertyCmdletParamMapping2.ReportObjectProperty].Add(reportPropertyCmdletParamMapping2.CmdletParameter); } } XmlNode annotationNode = ReportingSchema.SelectSingleNode(xmlNode2, "Annotation"); IReportAnnotation annotation = DependencyFactory.CreateReportAnnotation(annotationNode); IEntity entity = DependencyFactory.CreateEntity(text, new TaskInvocationInfo(text2, snapinName, dictionary), dictionary2, annotation); entity.Initialize(ipscommandResolver); this.entities.Add(text, entity); } } } }
public static IReportAnnotation Load(XmlNode annotationNode) { ReportAnnotation reportAnnotation = new ReportAnnotation(); reportAnnotation.reportTitle = ReportAnnotation.GetStringInfo(ReportingSchema.SelectSingleNode(annotationNode, "ReportTitle")); ReportingSchema.CheckCondition(reportAnnotation.reportTitle != null && !string.IsNullOrEmpty(reportAnnotation.reportTitle.StringId), "Report title isn't present."); reportAnnotation.xaxises = ReportAnnotation.LoadSeries(annotationNode, "XAxis"); reportAnnotation.yaxises = ReportAnnotation.LoadSeries(annotationNode, "YAxis"); ReportingSchema.CheckCondition(reportAnnotation.yaxises != null && reportAnnotation.yaxises.Count > 0, "Report Y-Axis doesn't present."); return(reportAnnotation); }