private Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> LoadRbacMapping(SafeXmlDocument doc) { Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> result; using (XmlNodeList xmlNodeList = doc.SelectNodes("/Configuration/CmdletParameterMappings/CmdletParameterMapping")) { Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]> dictionary = new Dictionary <string, ReportingSchema.ReportPropertyCmdletParamMapping[]>(xmlNodeList.Count); foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; using (XmlNodeList xmlNodeList2 = xmlNode.SelectNodes("Cmdlet")) { using (XmlNodeList xmlNodeList3 = xmlNode.SelectNodes("Mappings/Mapping")) { ReportingSchema.CheckCondition(xmlNodeList2.Count == 1, "There must be one and only one Cmdlet node under Rbac node."); string key = xmlNodeList2[0].Attributes["Name"].Value.Trim(); ReportingSchema.CheckCondition(!dictionary.ContainsKey(key), "There shouldn't be duplicate Cmdlet under Rbac node."); ReportingSchema.CheckCondition(xmlNodeList3.Count > 0, "The mapping shouldn't be empty."); ReportingSchema.ReportPropertyCmdletParamMapping[] array = new ReportingSchema.ReportPropertyCmdletParamMapping[xmlNodeList3.Count]; int num = 0; foreach (object obj2 in xmlNodeList3) { XmlNode xmlNode2 = (XmlNode)obj2; array[num++] = new ReportingSchema.ReportPropertyCmdletParamMapping(xmlNode2.Attributes["CmdletParameter"].Value.Trim(), xmlNode2.Attributes["ReportObjectProperty"].Value.Trim()); } dictionary.Add(key, array); } } } result = dictionary; } return(result); }
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); }
public static XmlNode SelectSingleNode(XmlNode node, string xpath) { XmlNode result; using (XmlNodeList xmlNodeList = node.SelectNodes(xpath)) { ReportingSchema.CheckCondition(xmlNodeList.Count == 1, string.Format("expect only one {0}.", xpath)); result = xmlNodeList[0]; } return(result); }