private void InitializeTuples() { string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames(); foreach (string text in manifestResourceNames) { if (text.EndsWith("EventLog.xml")) { SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.Load(Assembly.GetExecutingAssembly().GetManifestResourceStream(text)); Dictionary <string, short> dictionary = new Dictionary <string, short>(); foreach (object obj in safeXmlDocument.SelectNodes("/root/category")) { XmlElement xmlElement = (XmlElement)obj; string attribute = xmlElement.GetAttribute("name"); short value = short.Parse(xmlElement.SelectSingleNode("number").InnerText); dictionary.Add(attribute, value); } foreach (object obj2 in safeXmlDocument.SelectNodes("/root/data")) { XmlElement xmlElement2 = (XmlElement)obj2; string attribute2 = xmlElement2.GetAttribute("name"); uint eventId = (uint)Enum.Parse(typeof(MSExchangeDiagnosticsEventLogConstants.Message), attribute2); string innerText = xmlElement2.SelectSingleNode("category").InnerText; string innerText2 = xmlElement2.SelectSingleNode("stringvalue").InnerText; short categoryId = dictionary[innerText]; string innerText3 = xmlElement2.SelectSingleNode("eventtype").InnerText; string component = string.Empty; XmlNode xmlNode = xmlElement2.SelectSingleNode("component"); if (xmlNode != null) { component = EventLogger.FormatString(xmlNode.InnerText); } string tag = string.Empty; XmlNode xmlNode2 = xmlElement2.SelectSingleNode("tag"); if (xmlNode2 != null) { tag = EventLogger.FormatString(xmlNode2.InnerText); } string exception = string.Empty; XmlNode xmlNode3 = xmlElement2.SelectSingleNode("exception"); if (xmlNode3 != null) { exception = EventLogger.FormatString(xmlNode3.InnerText); } EventLogEntryType enumValue = EventLogger.GetEnumValue <EventLogEntryType>(xmlElement2, "eventtype"); ExEventLog.EventLevel enumValue2 = EventLogger.GetEnumValue <ExEventLog.EventLevel>(xmlElement2, "level"); ExEventLog.EventPeriod enumValue3 = EventLogger.GetEnumValue <ExEventLog.EventPeriod>(xmlElement2, "period"); ExEventLog.EventTuple tuple = new ExEventLog.EventTuple(eventId, categoryId, enumValue, enumValue2, enumValue3); this.tuples.Add(attribute2, new EventLogger.EventData(tuple, component, tag, exception)); string text2 = EventLogger.FormatString(innerText2); if (!TriggerHandler.Triggers.ContainsKey(attribute2)) { TriggerHandler.Triggers.Add(attribute2, new TriggerHandler.TriggerData(innerText3, text2)); } } } } }
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); }
internal static void RegisterCounters(string installationPath) { string filename = Path.Combine(installationPath, "Microsoft.Exchange.Diagnostics.Service.Common.EdsPerformanceCounters.xml"); SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.Load(filename); string text = LoadEdsPerformanceCounters.ReadStringElement(safeXmlDocument, "Category/Name"); Logger.LogInformationMessage("Found performance counter category {0}", new object[] { text }); if (!LoadEdsPerformanceCounters.SafeExists(text)) { Logger.LogInformationMessage("Registering EDS performance counters.", new object[0]); CounterCreationDataCollection counterCreationDataCollection = new CounterCreationDataCollection(); XmlNodeList xmlNodeList = safeXmlDocument.SelectNodes("Category/Counters/Counter"); using (xmlNodeList) { for (int i = 0; i < xmlNodeList.Count; i++) { string text2 = LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Name"); PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), LoadEdsPerformanceCounters.ReadStringElement(xmlNodeList[i], "Type"), true); counterCreationDataCollection.Add(new CounterCreationData(text2, string.Empty, counterType)); Logger.LogInformationMessage("Loaded counter {0}", new object[] { text2 }); } } LoadEdsPerformanceCounters.SafeCreate(text, counterCreationDataCollection); return; } Logger.LogInformationMessage("Counters are already registered.", new object[0]); }
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 ObjectSchemaLoader(DataDrivenCategory dataDrivenCategory, string xPath, string schema) { Stream manifestResource = WinformsHelper.GetManifestResource(dataDrivenCategory); SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.Load(manifestResource); foreach (object obj in safeXmlDocument.SelectNodes(xPath)) { XmlNode xmlNode = (XmlNode)obj; XmlNode namedItem = xmlNode.Attributes.GetNamedItem("Name"); if (namedItem.Value.Equals(schema)) { this.objectDefinition = xmlNode; break; } } }
private XmlElement FindOrCreateElement(SafeXmlDocument xmlDoc, bool create) { string[] array = this.Element.Split(new char[] { '\\', '/' }); XmlNode xmlNode = null; bool flag = true; string text = array[0]; using (XmlNodeList xmlNodeList = xmlDoc.SelectNodes(text)) { if (xmlNodeList.Count != 1) { base.WriteError(new LocalizedException(Strings.RootNodeDoesNotMatch(text, this.ConfigFileFullPath)), (ErrorCategory)1003, null); } XmlNode xmlNode2; xmlNode = (xmlNode2 = xmlNodeList[0]); int i = 1; while (i < array.GetLength(0)) { text = array[i]; if (flag) { using (XmlNodeList xmlNodeList2 = xmlNode2.SelectNodes(text)) { if (xmlNodeList2.Count > 1) { base.WriteError(new LocalizedException(Strings.NodeNotUnique(text, this.ConfigFileFullPath)), (ErrorCategory)1003, null); } else if (xmlNodeList2.Count == 1) { xmlNode = xmlNodeList2[0]; } else { if (!create) { return(null); } xmlNode = this.CreateChild(xmlDoc, xmlNode2, text); flag = false; } goto IL_F9; } goto IL_E5; } goto IL_E5; IL_F9: xmlNode2 = xmlNode; i++; continue; IL_E5: if (create) { xmlNode = this.CreateChild(xmlDoc, xmlNode2, text); goto IL_F9; } return(null); } } XmlElement xmlElement = xmlNode as XmlElement; if (xmlElement == null) { base.WriteError(new LocalizedException(Strings.NodeNotElement(xmlNode.Name, this.ConfigFileFullPath)), (ErrorCategory)1003, null); } return(xmlElement); }
internal void Load(Dictionary <string, StoreDriverParameterHandler> keyHandlerCollection) { if (keyHandlerCollection == null) { return; } Assembly executingAssembly = Assembly.GetExecutingAssembly(); string text = Path.Combine(Path.GetDirectoryName(executingAssembly.Location), "StoreDriver.config"); if (!File.Exists(text)) { StoreDriverParameters.diag.TraceError <string>(0L, "The config file {0} does not exist.", text); return; } XmlSchemaSet xmlSchemaSet = new XmlSchemaSet(); try { using (Stream manifestResourceStream = executingAssembly.GetManifestResourceStream("StoreDriverParameters.xsd")) { if (manifestResourceStream == null) { StoreDriverParameters.diag.TraceDebug <string>(0L, "The schema resource {0} does not exist.", "StoreDriverParameters.xsd"); return; } xmlSchemaSet.Add(null, SafeXmlFactory.CreateSafeXmlTextReader(manifestResourceStream)); } } catch (FileLoadException arg) { StoreDriverParameters.diag.TraceError <string, FileLoadException>(0L, "Failed to load the manifest resource stream {0}. Error {1}", "StoreDriverParameters.xsd", arg); return; } catch (FileNotFoundException arg2) { StoreDriverParameters.diag.TraceError <string, FileNotFoundException>(0L, "Failed to find the manifest resource stream {0}.Error: {1}", text, arg2); return; } Exception ex = null; try { xmlSchemaSet.Compile(); XmlDocument xmlDocument = new SafeXmlDocument(); xmlDocument.Schemas = xmlSchemaSet; using (FileStream fileStream = new FileStream(text, FileMode.Open, FileAccess.Read, FileShare.Read)) { xmlDocument.Load(fileStream); XmlNodeList xmlNodeList = xmlDocument.SelectNodes("/configuration/storeDriver/parameters/add"); foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; if (xmlNode != null && xmlNode is XmlElement) { this.currentNodeValid = true; xmlDocument.Validate(delegate(object sender, ValidationEventArgs args) { StoreDriverParameters.diag.TraceDebug <string>(0L, "The parameter or value is invalid: {0}.", args.Message); this.currentNodeValid = false; }, xmlNode); if (this.currentNodeValid) { string value = xmlNode.Attributes.GetNamedItem("key").Value; string value2 = xmlNode.Attributes.GetNamedItem("value").Value; if (value != null && value2 != null && keyHandlerCollection.ContainsKey(value)) { keyHandlerCollection[value](value, value2); } } } } } } catch (XmlSchemaException ex2) { ex = ex2; } catch (SecurityException ex3) { ex = ex3; } catch (IOException ex4) { ex = ex4; } catch (XmlException ex5) { ex = ex5; } catch (XPathException ex6) { ex = ex6; } if (ex != null) { StoreDriverParameters.diag.TraceError <Exception>(0L, "Failed to load parameters from storedriver config. Will use default values. Error: {0}", ex); } }
// Token: 0x06000BB5 RID: 2997 RVA: 0x0002FB58 File Offset: 0x0002DD58 protected override void ParseResponse(byte[] responseBuffer, int responseBufferSize) { Dictionary <string, string> dictionary = new Dictionary <string, string>(); Dictionary <string, string> dictionary2 = new Dictionary <string, string>(); try { using (MemoryStream memoryStream = new MemoryStream(responseBuffer, 0, responseBuffer.Length)) { SafeXmlDocument safeXmlDocument = new SafeXmlDocument(); safeXmlDocument.PreserveWhitespace = true; safeXmlDocument.Load(memoryStream); XmlNamespaceManager xmlNamespaceManager = new XmlNamespaceManager(safeXmlDocument.NameTable); xmlNamespaceManager.AddNamespace("o", "urn:schemas-microsoft-com:office:office"); XmlNodeList xmlNodeList = safeXmlDocument.SelectNodes("/o:assets/o:asset", xmlNamespaceManager); foreach (object obj in xmlNodeList) { XmlNode xmlNode = (XmlNode)obj; string attributeStringValue = ExtensionData.GetAttributeStringValue(xmlNode, "o:cm"); string attributeStringValue2 = ExtensionData.GetAttributeStringValue(xmlNode, "o:assetid"); string value = HttpUtility.UrlEncode(HttpUtility.HtmlDecode(ExtensionData.GetAttributeStringValue(xmlNode, "o:etok"))); bool flag = false; string optionalAttributeStringValue = ExtensionData.GetOptionalAttributeStringValue(xmlNode, "o:status", string.Empty); foreach (TokenRenewRequestAsset tokenRenewRequestAsset in this.extensionTokenRenewList) { if (string.Equals(tokenRenewRequestAsset.MarketplaceAssetID, attributeStringValue2, StringComparison.OrdinalIgnoreCase) && string.Equals(tokenRenewRequestAsset.MarketplaceContentMarket, attributeStringValue, StringComparison.OrdinalIgnoreCase)) { tokenRenewRequestAsset.IsResponseFound = true; if ("1".Equals(optionalAttributeStringValue, StringComparison.OrdinalIgnoreCase)) { dictionary.Add(tokenRenewRequestAsset.ExtensionID, value); } else if ("6".Equals(optionalAttributeStringValue, StringComparison.OrdinalIgnoreCase)) { dictionary2.Add(tokenRenewRequestAsset.ExtensionID, "2.1"); } else { dictionary2.Add(tokenRenewRequestAsset.ExtensionID, "2.0"); } flag = true; break; } } if (!flag) { BaseAsyncCommand.Tracer.TraceError <string, string, string>(0L, "The returned token does not match the asset and marketplace in the request. Asset id: {0} Marketplace: {1} Status code: {2}.", attributeStringValue2, attributeStringValue, optionalAttributeStringValue); ExtensionDiagnostics.Logger.LogEvent(ApplicationLogicEventLogConstants.Tuple_MismatchedReturnedToken, attributeStringValue2, new object[] { this.scenario, this.requestId, base.GetLoggedMailboxIdentifier(), attributeStringValue2, attributeStringValue, optionalAttributeStringValue }); } } foreach (TokenRenewRequestAsset tokenRenewRequestAsset2 in this.extensionTokenRenewList) { if (!tokenRenewRequestAsset2.IsResponseFound) { dictionary2.Add(tokenRenewRequestAsset2.ExtensionID, "2.0"); } } } } catch (XmlException exception) { this.InternalFailureCallback(exception, null); return; } base.LogResponseParsed(); this.successCallback(dictionary, dictionary2); }