Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / whidbey / NetFXspW7 / 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
- SerializationFieldInfo.cs
- ToolboxDataAttribute.cs
- MethodBuilderInstantiation.cs
- MetadataUtil.cs
- TailCallAnalyzer.cs
- SerialErrors.cs
- WindowVisualStateTracker.cs
- WorkflowDefinitionContext.cs
- BamlReader.cs
- HandleCollector.cs
- PolicyValidator.cs
- SrgsElementFactoryCompiler.cs
- AbstractExpressions.cs
- Expression.cs
- Transform.cs
- SerTrace.cs
- GeneralTransform.cs
- XmlException.cs
- _ChunkParse.cs
- WebPartAddingEventArgs.cs
- NavigateEvent.cs
- UserControl.cs
- DataGridViewSelectedCellsAccessibleObject.cs
- StatusBarItemAutomationPeer.cs
- InstanceStore.cs
- CroppedBitmap.cs
- InstanceCreationEditor.cs
- CngKey.cs
- WebPartDisplayModeEventArgs.cs
- DbProviderFactoriesConfigurationHandler.cs
- ClientBuildManagerTypeDescriptionProviderBridge.cs
- CatalogZoneAutoFormat.cs
- MobileControlDesigner.cs
- SimpleColumnProvider.cs
- SmiRecordBuffer.cs
- SplitterPanel.cs
- MergeLocalizationDirectives.cs
- HttpResponseInternalBase.cs
- WebPartZone.cs
- DeferredElementTreeState.cs
- DataGridViewDataConnection.cs
- RoutingTable.cs
- ColumnResult.cs
- SqlUserDefinedTypeAttribute.cs
- DoubleAnimationUsingPath.cs
- Panel.cs
- Size.cs
- EventNotify.cs
- TextTreePropertyUndoUnit.cs
- InputLangChangeRequestEvent.cs
- VerificationException.cs
- FontFamilyIdentifier.cs
- OleDbFactory.cs
- sqlser.cs
- UInt32Converter.cs
- _HeaderInfoTable.cs
- DesignerMetadata.cs
- ParameterModifier.cs
- ListViewItem.cs
- VisualStyleRenderer.cs
- XmlKeywords.cs
- HtmlFormParameterWriter.cs
- SqlDataSourceCommandEventArgs.cs
- FileDialog_Vista.cs
- TableCellCollection.cs
- DefaultEvaluationContext.cs
- QueryStringParameter.cs
- DesigntimeLicenseContextSerializer.cs
- SiteMapSection.cs
- Funcletizer.cs
- DrawingCollection.cs
- PropertyConverter.cs
- FormParameter.cs
- ModelItemDictionary.cs
- ModelItemCollection.cs
- CultureInfoConverter.cs
- CLRBindingWorker.cs
- DefaultMemberAttribute.cs
- TypeDescriptor.cs
- TempFiles.cs
- NavigationCommands.cs
- RightsDocument.cs
- UnsafeNativeMethods.cs
- SourceLineInfo.cs
- DeliveryStrategy.cs
- xsdvalidator.cs
- CodeArrayIndexerExpression.cs
- XmlWriterTraceListener.cs
- SectionVisual.cs
- SoapServerMessage.cs
- CSharpCodeProvider.cs
- GuidConverter.cs
- ClipboardData.cs
- X509InitiatorCertificateServiceElement.cs
- FloaterParagraph.cs
- ScrollBarAutomationPeer.cs
- Int32Converter.cs
- MappedMetaModel.cs
- CodeNamespaceImport.cs
- ToolboxComponentsCreatingEventArgs.cs