protected bool ValidateXmlNode(XmlNode xmlNode, string targetNamespace) { bool result; using (Command.CurrentCommand.Context.Tracker.Start(TimeId.ValidatorValidateXMLNode)) { if (!Validator.schemasCreated) { Validator.CreateSchemaSet(); } xmlNode.OwnerDocument.Schemas = Validator.schemas[this.versionIdx]; ICollection collection = xmlNode.OwnerDocument.Schemas.Schemas(targetNamespace); if (collection == null || collection.Count == 0) { if (AirSyncDiagnostics.IsTraceEnabled(TraceType.ErrorTrace, ExTraceGlobals.ValidationTracer)) { AirSyncDiagnostics.TraceError <string, string>(ExTraceGlobals.ValidationTracer, null, "Validaton Failure No Schema specified for {0} TargetNamespace={1}", xmlNode.OwnerDocument.LocalName, targetNamespace); } this.ValidationErrors.Add(new Validator.XmlValidationError("Unknown Namespace: '{0}'", new object[] { targetNamespace })); result = false; } else { this.failed = false; xmlNode.OwnerDocument.Validate(new ValidationEventHandler(this.AirSyncValidationEventHandler), xmlNode); result = !this.failed; } } return(result); }
private void AirSyncValidationEventHandler(object sender, ValidationEventArgs args) { this.failed = true; this.ValidationErrors.Add(new Validator.XmlValidationError(args)); if (AirSyncDiagnostics.IsTraceEnabled(TraceType.ErrorTrace, ExTraceGlobals.ValidationTracer)) { StringBuilder stringBuilder = new StringBuilder(); XmlSchemaValidationException ex = args.Exception as XmlSchemaValidationException; if (ex != null && ex.SourceObject != null) { XmlElement xmlElement = ex.SourceObject as XmlElement; if (xmlElement != null) { stringBuilder.Append("Source=").Append(xmlElement.InnerXml); } if (args.Exception.LineNumber != 0) { stringBuilder.Append("Line=").Append(args.Exception.LineNumber); } if (args.Exception.StackTrace != null) { stringBuilder.Append("Stack=").Append(args.Exception.StackTrace); } } AirSyncDiagnostics.TraceError <XmlSeverityType, string, StringBuilder>(ExTraceGlobals.ValidationTracer, null, "Validaton Failure Severity={0} Message={1} {2}", args.Severity, args.Message, stringBuilder); } }
internal virtual bool ValidateXml(XmlElement rootNode, string rootNodeName) { bool result; using (Command.CurrentCommand.Context.Tracker.Start(TimeId.ValidatorValidateXML)) { this.ValidationErrors.Clear(); if (!GlobalSettings.Validate) { result = true; } else if (this.versionIdx < 0 || this.versionIdx >= Validator.airsyncVersion.Length) { this.ValidationErrors.Add(new Validator.XmlValidationError("Request contained unknown version: {0}.{1}", new object[] { this.Version / 10, this.Version % 10 })); result = false; } else { if (rootNode == null) { throw new AirSyncPermanentException(HttpStatusCode.BadRequest, StatusCode.First140Error, null, false); } if (rootNode.LocalName != rootNodeName) { if (AirSyncDiagnostics.IsTraceEnabled(TraceType.ErrorTrace, ExTraceGlobals.ValidationTracer)) { AirSyncDiagnostics.TraceError <XmlDocument, string, string>(ExTraceGlobals.ValidationTracer, null, "Validaton Failure InvalidRootNode {0} ExpectedNode={1} FoundNode={2}", rootNode.OwnerDocument, rootNodeName, rootNode.LocalName); } this.ValidationErrors.Add(new Validator.XmlValidationError("Invalid Root Node. Expected: '{0}' Found: '{1}'", new object[] { rootNodeName, rootNode.LocalName })); result = false; } else { result = this.ValidateXmlNode(rootNode, rootNode.NamespaceURI); } } } return(result); }
void IAirSyncRequest.TraceHeaders() { if (AirSyncDiagnostics.IsTraceEnabled(TraceType.DebugTrace, ExTraceGlobals.RequestsTracer)) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Request headers:"); AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.RequestsTracer, this, " {0} {1} HTTP/1.1", this.httpRequest.HttpMethod, this.httpRequest.Url.PathAndQuery); foreach (object obj in this.httpRequest.Headers) { string text = (string)obj; if (string.Equals(text, "authorization", StringComparison.OrdinalIgnoreCase)) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, " {0}: ********", text); } else { AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.RequestsTracer, this, " {0}: {1}", text, this.httpRequest.Headers[text]); } } } }
// Token: 0x06000281 RID: 641 RVA: 0x0000E718 File Offset: 0x0000C918 void IAirSyncResponse.TraceHeaders() { if (AirSyncDiagnostics.IsTraceEnabled(TraceType.DebugTrace, ExTraceGlobals.RequestsTracer)) { AirSyncDiagnostics.TraceDebug(ExTraceGlobals.RequestsTracer, this, "Response headers:"); AirSyncDiagnostics.TraceDebug <int, string>(ExTraceGlobals.RequestsTracer, this, " HTTP/1.1 {0} {1}", this.httpResponse.StatusCode, this.httpResponse.StatusDescription); foreach (string text in this.responseHeaders.Keys) { foreach (string arg in this.responseHeaders[text]) { if (string.Equals(text, "authorization", StringComparison.OrdinalIgnoreCase)) { AirSyncDiagnostics.TraceDebug <string>(ExTraceGlobals.RequestsTracer, this, " {0}: ********", text); } else { AirSyncDiagnostics.TraceDebug <string, string>(ExTraceGlobals.RequestsTracer, this, " {0}: {1}", text, arg); } } } } }