Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / XmlUtils / System / Xml / Xsl / XPath / XPathCompileException.cs / 1 / XPathCompileException.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Runtime.Serialization; using System.Security.Permissions; using System.Text; namespace System.Xml.Xsl.XPath { [Serializable] internal class XPathCompileException : XslLoadException { public string queryString; public int startChar; public int endChar; protected XPathCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { queryString = (string)info.GetValue("QueryString", typeof(string)); startChar = (int) info.GetValue("StartChar" , typeof(int )); endChar = (int) info.GetValue("EndChar" , typeof(int )); } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("QueryString", queryString); info.AddValue("StartChar" , startChar); info.AddValue("EndChar" , endChar); } internal XPathCompileException(string queryString, int startChar, int endChar, string resId, params string[] args) : base(resId, args) { this.queryString = queryString; this.startChar = startChar; this.endChar = endChar; } internal XPathCompileException(string resId, params string[] args) : base(resId, args) {} // queryString will be set later private enum TrimType { Left, Right, Middle, } // This function is used to prevent long quotations in error messages, SQLBUDT 222626 private static void AppendTrimmed(StringBuilder sb, string value, int startIndex, int count, TrimType trimType) { const int TrimSize = 32; const string TrimMarker = "..."; if (count <= TrimSize) { sb.Append(value, startIndex, count); } else { switch (trimType) { case TrimType.Left: sb.Append(TrimMarker); sb.Append(value, startIndex + count - TrimSize, TrimSize); break; case TrimType.Right: sb.Append(value, startIndex, TrimSize); sb.Append(TrimMarker); break; case TrimType.Middle: sb.Append(value, startIndex, TrimSize / 2); sb.Append(TrimMarker); sb.Append(value, startIndex + count - TrimSize / 2, TrimSize / 2); break; } } } internal string MarkOutError() { if (queryString == null || queryString.Trim(' ').Length == 0) { return null; } int len = endChar - startChar; StringBuilder sb = new StringBuilder(); AppendTrimmed(sb, queryString, 0, startChar, TrimType.Left); if (len > 0) { sb.Append(" -->"); AppendTrimmed(sb, queryString, startChar, len, TrimType.Middle); } sb.Append("<-- "); AppendTrimmed(sb, queryString, endChar, queryString.Length - endChar, TrimType.Right); return sb.ToString(); } internal override string FormatDetailedMessage() { string message = Message; string error = MarkOutError(); if (error != null && error.Length > 0) { if (message.Length > 0) { message += Environment.NewLine; } message += error; } return message; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //[....] //----------------------------------------------------------------------------- using System.Runtime.Serialization; using System.Security.Permissions; using System.Text; namespace System.Xml.Xsl.XPath { [Serializable] internal class XPathCompileException : XslLoadException { public string queryString; public int startChar; public int endChar; protected XPathCompileException(SerializationInfo info, StreamingContext context) : base(info, context) { queryString = (string)info.GetValue("QueryString", typeof(string)); startChar = (int) info.GetValue("StartChar" , typeof(int )); endChar = (int) info.GetValue("EndChar" , typeof(int )); } [SecurityPermissionAttribute(SecurityAction.Demand, SerializationFormatter = true)] public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("QueryString", queryString); info.AddValue("StartChar" , startChar); info.AddValue("EndChar" , endChar); } internal XPathCompileException(string queryString, int startChar, int endChar, string resId, params string[] args) : base(resId, args) { this.queryString = queryString; this.startChar = startChar; this.endChar = endChar; } internal XPathCompileException(string resId, params string[] args) : base(resId, args) {} // queryString will be set later private enum TrimType { Left, Right, Middle, } // This function is used to prevent long quotations in error messages, SQLBUDT 222626 private static void AppendTrimmed(StringBuilder sb, string value, int startIndex, int count, TrimType trimType) { const int TrimSize = 32; const string TrimMarker = "..."; if (count <= TrimSize) { sb.Append(value, startIndex, count); } else { switch (trimType) { case TrimType.Left: sb.Append(TrimMarker); sb.Append(value, startIndex + count - TrimSize, TrimSize); break; case TrimType.Right: sb.Append(value, startIndex, TrimSize); sb.Append(TrimMarker); break; case TrimType.Middle: sb.Append(value, startIndex, TrimSize / 2); sb.Append(TrimMarker); sb.Append(value, startIndex + count - TrimSize / 2, TrimSize / 2); break; } } } internal string MarkOutError() { if (queryString == null || queryString.Trim(' ').Length == 0) { return null; } int len = endChar - startChar; StringBuilder sb = new StringBuilder(); AppendTrimmed(sb, queryString, 0, startChar, TrimType.Left); if (len > 0) { sb.Append(" -->"); AppendTrimmed(sb, queryString, startChar, len, TrimType.Middle); } sb.Append("<-- "); AppendTrimmed(sb, queryString, endChar, queryString.Length - endChar, TrimType.Right); return sb.ToString(); } internal override string FormatDetailedMessage() { string message = Message; string error = MarkOutError(); if (error != null && error.Length > 0) { if (message.Length > 0) { message += Environment.NewLine; } message += error; } return message; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CellNormalizer.cs
- Clause.cs
- BridgeDataReader.cs
- ObjectDataSource.cs
- SecurityContext.cs
- listitem.cs
- WindowsClaimSet.cs
- XmlComplianceUtil.cs
- HtmlPageAdapter.cs
- Double.cs
- SerTrace.cs
- TimeManager.cs
- CalendarDateChangedEventArgs.cs
- Trace.cs
- DataGridView.cs
- ClientSponsor.cs
- RadioButtonRenderer.cs
- RelationshipConverter.cs
- UIElement3DAutomationPeer.cs
- PreDigestedSignedInfo.cs
- TableLayoutSettingsTypeConverter.cs
- TableProviderWrapper.cs
- SqlConnectionPoolProviderInfo.cs
- EpmTargetPathSegment.cs
- LogPolicy.cs
- Processor.cs
- ArrayConverter.cs
- SafeRightsManagementSessionHandle.cs
- MenuItem.cs
- XMLDiffLoader.cs
- httpapplicationstate.cs
- TraceContext.cs
- ExpandSegmentCollection.cs
- BindableTemplateBuilder.cs
- DataGridViewUtilities.cs
- ConfigXmlSignificantWhitespace.cs
- MetadataCacheItem.cs
- VariableBinder.cs
- XmlCDATASection.cs
- StateManagedCollection.cs
- WebRequestModuleElementCollection.cs
- TableProviderWrapper.cs
- Char.cs
- TextTreeDeleteContentUndoUnit.cs
- WebPartChrome.cs
- DataBoundControlDesigner.cs
- base64Transforms.cs
- Expressions.cs
- ObjectNotFoundException.cs
- BamlRecordWriter.cs
- XmlEventCache.cs
- XhtmlBasicImageAdapter.cs
- RegexStringValidatorAttribute.cs
- Dispatcher.cs
- _SslState.cs
- ObjectKeyFrameCollection.cs
- StrokeNodeOperations.cs
- StateDesigner.LayoutSelectionGlyph.cs
- MethodInfo.cs
- ToolStripDropDownClosingEventArgs.cs
- StoryFragments.cs
- DataIdProcessor.cs
- LoadWorkflowAsyncResult.cs
- EncoderExceptionFallback.cs
- XmlSerializationWriter.cs
- SuppressIldasmAttribute.cs
- WindowsFont.cs
- GrammarBuilderBase.cs
- SQLByte.cs
- BindingValueChangedEventArgs.cs
- _CommandStream.cs
- BitmapEffectInputData.cs
- ProxyWebPartConnectionCollection.cs
- DetailsViewInsertEventArgs.cs
- AdPostCacheSubstitution.cs
- DoubleCollectionConverter.cs
- handlecollector.cs
- ReversePositionQuery.cs
- SQLString.cs
- XmlSchemaType.cs
- FormDesigner.cs
- DragAssistanceManager.cs
- Section.cs
- RadioButton.cs
- SymbolTable.cs
- BrowserCapabilitiesFactoryBase.cs
- ExeContext.cs
- TranslateTransform3D.cs
- EntityCommandDefinition.cs
- HtmlContainerControl.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- SqlNode.cs
- FormatterServices.cs
- MetadataPropertyCollection.cs
- XmlSchemaInferenceException.cs
- ActivityInterfaces.cs
- Queue.cs
- ProcessHostServerConfig.cs
- EndPoint.cs
- SystemWebSectionGroup.cs