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
- GregorianCalendarHelper.cs
- ProjectionQueryOptionExpression.cs
- DynamicFilter.cs
- EncodingTable.cs
- AlphaSortedEnumConverter.cs
- CqlParserHelpers.cs
- XslVisitor.cs
- PopupControlService.cs
- TabPanel.cs
- DummyDataSource.cs
- MenuStrip.cs
- ContractListAdapter.cs
- MSHTMLHostUtil.cs
- AudioException.cs
- SortQuery.cs
- ComponentEditorPage.cs
- WindowsTooltip.cs
- DrawToolTipEventArgs.cs
- SqlGenerator.cs
- BridgeDataRecord.cs
- RequestResizeEvent.cs
- WindowsIdentity.cs
- VirtualizingStackPanel.cs
- SHA1.cs
- OleStrCAMarshaler.cs
- StorageAssociationSetMapping.cs
- SetIterators.cs
- Effect.cs
- RectValueSerializer.cs
- HttpAsyncResult.cs
- cache.cs
- Message.cs
- StateValidator.cs
- StandardCommands.cs
- FirstMatchCodeGroup.cs
- ErrorTableItemStyle.cs
- GenericWebPart.cs
- Int32AnimationUsingKeyFrames.cs
- StreamWriter.cs
- UnicastIPAddressInformationCollection.cs
- DataControlField.cs
- DataColumnPropertyDescriptor.cs
- EntityClientCacheKey.cs
- StrongNameKeyPair.cs
- PolicyValidationException.cs
- TransformerConfigurationWizardBase.cs
- TabPanel.cs
- RoleGroup.cs
- GeneralTransform3D.cs
- HostingEnvironmentWrapper.cs
- AbandonedMutexException.cs
- RepeaterItemCollection.cs
- SafeProcessHandle.cs
- MLangCodePageEncoding.cs
- MenuEventArgs.cs
- TextAutomationPeer.cs
- UniqueEventHelper.cs
- DoubleUtil.cs
- CompiledIdentityConstraint.cs
- VerbConverter.cs
- RootBrowserWindowProxy.cs
- GradientStop.cs
- ISessionStateStore.cs
- LogExtent.cs
- _Semaphore.cs
- MdiWindowListItemConverter.cs
- ServiceTimeoutsElement.cs
- Type.cs
- OdbcTransaction.cs
- ModuleConfigurationInfo.cs
- PropertyDescriptorGridEntry.cs
- BulletChrome.cs
- BindUriHelper.cs
- CapabilitiesAssignment.cs
- InheritedPropertyDescriptor.cs
- KernelTypeValidation.cs
- SemaphoreSlim.cs
- ISAPIApplicationHost.cs
- AssemblyName.cs
- UnsafeNativeMethods.cs
- PnrpPeerResolverElement.cs
- ResourceExpressionBuilder.cs
- Model3DGroup.cs
- PropertyEmitter.cs
- CqlErrorHelper.cs
- IntSecurity.cs
- BaseParagraph.cs
- NativeMethods.cs
- SubstitutionDesigner.cs
- DocumentsTrace.cs
- ProfileProvider.cs
- EnvironmentPermission.cs
- Icon.cs
- QuotedPrintableStream.cs
- SchemaLookupTable.cs
- CompensableActivity.cs
- WebPartDisplayModeCancelEventArgs.cs
- SafeRightsManagementPubHandle.cs
- SHA1CryptoServiceProvider.cs
- RoleBoolean.cs