Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / 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
- AnnotationAdorner.cs
- PageTheme.cs
- M3DUtil.cs
- ZipIOCentralDirectoryDigitalSignature.cs
- Pen.cs
- QueryPageSettingsEventArgs.cs
- HwndStylusInputProvider.cs
- ApplicationSettingsBase.cs
- CompilerErrorCollection.cs
- WindowsFormsHelpers.cs
- TeredoHelper.cs
- WindowsListViewItemStartMenu.cs
- _NestedSingleAsyncResult.cs
- DbConnectionPoolGroupProviderInfo.cs
- ScriptControlDescriptor.cs
- VariableModifiersHelper.cs
- ComponentEditorForm.cs
- TemplateContainer.cs
- RankException.cs
- XmlSchemaObject.cs
- ListViewDeleteEventArgs.cs
- CapacityStreamGeometryContext.cs
- FieldToken.cs
- ListItemCollection.cs
- Intellisense.cs
- SafeHandles.cs
- DataGridItemEventArgs.cs
- ProfileProvider.cs
- ObjectDataSourceStatusEventArgs.cs
- CodeMethodInvokeExpression.cs
- Variable.cs
- SplitterPanel.cs
- DataSourceControlBuilder.cs
- ExtractedStateEntry.cs
- VerificationAttribute.cs
- StringToken.cs
- VariableModifiersHelper.cs
- StaticFileHandler.cs
- KeyInstance.cs
- InputBuffer.cs
- XmlBinaryReader.cs
- AsyncOperationManager.cs
- InternalConfigConfigurationFactory.cs
- Attributes.cs
- Cursor.cs
- CustomSignedXml.cs
- SplashScreen.cs
- IgnoreSection.cs
- XmlSchemaInclude.cs
- Int16AnimationUsingKeyFrames.cs
- Int32AnimationBase.cs
- COM2Properties.cs
- Translator.cs
- SystemInformation.cs
- FileAuthorizationModule.cs
- dataprotectionpermissionattribute.cs
- MenuStrip.cs
- WebBrowserNavigatingEventHandler.cs
- XmlDesignerDataSourceView.cs
- RowToParametersTransformer.cs
- DataStorage.cs
- IntSecurity.cs
- FrameworkElementFactoryMarkupObject.cs
- MarginsConverter.cs
- QuarticEase.cs
- TextAction.cs
- Selection.cs
- UnauthorizedWebPart.cs
- Command.cs
- VarRefManager.cs
- SR.cs
- ResourceDefaultValueAttribute.cs
- StylusPointDescription.cs
- CompressionTransform.cs
- CommandHelper.cs
- UInt32.cs
- GB18030Encoding.cs
- PartitionResolver.cs
- LongSumAggregationOperator.cs
- DataExpression.cs
- ListBoxItemAutomationPeer.cs
- GridViewItemAutomationPeer.cs
- IntSecurity.cs
- X509ChainElement.cs
- PropertyGrid.cs
- HttpCookieCollection.cs
- Propagator.Evaluator.cs
- ProxyGenerationError.cs
- Error.cs
- ValidatingPropertiesEventArgs.cs
- MergeFailedEvent.cs
- TrackingRecord.cs
- AutoSizeComboBox.cs
- HttpRuntime.cs
- EndpointAddressProcessor.cs
- ServiceSecurityContext.cs
- EndpointDispatcherTable.cs
- XamlReaderConstants.cs
- ValuePatternIdentifiers.cs
- MultipartContentParser.cs