Code:
/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / clr / src / BCL / System / Diagnostics / Assert.cs / 1 / Assert.cs
// ==++== // // Copyright (c) Microsoft Corporation. All rights reserved. // // ==--== namespace System.Diagnostics { using System; using System.Security.Permissions; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; // Class which handles code asserts. Asserts are used to explicitly protect // assumptions made in the code. In general if an assert fails, it indicates // a program bug so is immediately called to the attention of the user. // Only static data members, does not need to be marked with the serializable attribute internal static class Assert { private static AssertFilter[] ListOfFilters; private static int iNumOfFilters; private static int iFilterArraySize; static Assert() { Assert.AddFilter(new DefaultFilter()); } // AddFilter adds a new assert filter. This replaces the current // filter, unless the filter returns FailContinue. // public static void AddFilter(AssertFilter filter) { if (iFilterArraySize <= iNumOfFilters) { AssertFilter[] newFilterArray = new AssertFilter [iFilterArraySize+2]; if (iNumOfFilters > 0) Array.Copy(ListOfFilters, newFilterArray, iNumOfFilters); iFilterArraySize += 2; ListOfFilters = newFilterArray; } ListOfFilters [iNumOfFilters++] = filter; } // Called when an assertion is being made. // public static void Check(bool condition, String conditionString, String message) { if (!condition) { Fail (conditionString, message); } } public static void Fail(String conditionString, String message) { // get the stacktrace StackTrace st = new StackTrace(); // Run through the list of filters backwards (the last filter in the list // is the default filter. So we're guaranteed that there will be atleast // one filter to handle the assert. int iTemp = iNumOfFilters; while (iTemp > 0) { AssertFilters iResult = ListOfFilters [--iTemp].AssertFailure (conditionString, message, st); if (iResult == AssertFilters.FailDebug) { if (Debugger.IsAttached == true) Debugger.Break(); else { if (Debugger.Launch() == false) { throw new InvalidOperationException( Environment.GetResourceString("InvalidOperation_DebuggerLaunchFailed")); } } break; } else if (iResult == AssertFilters.FailTerminate) Environment.Exit(-1); else if (iResult == AssertFilters.FailIgnore) break; // If none of the above, it means that the Filter returned FailContinue. // So invoke the next filter. } } // Called when an assert happens. // [MethodImplAttribute(MethodImplOptions.InternalCall)] public extern static int ShowDefaultAssertDialog(String conditionString, String message); } }
Link Menu
![Network programming in C#, Network Programming in VB.NET, Network Programming in .NET](/images/book.jpg)
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- AlphaSortedEnumConverter.cs
- CallContext.cs
- ArglessEventHandlerProxy.cs
- WindowsFormsSectionHandler.cs
- RectangleGeometry.cs
- __Error.cs
- TextShapeableCharacters.cs
- Menu.cs
- Floater.cs
- HtmlFormWrapper.cs
- Hash.cs
- SerializationSectionGroup.cs
- OracleCommandSet.cs
- WorkflowCommandExtensionItem.cs
- MultiSelectRootGridEntry.cs
- CollectionViewProxy.cs
- LogicalExpressionTypeConverter.cs
- AnnotationResourceChangedEventArgs.cs
- OpenFileDialog.cs
- Executor.cs
- SafeCancelMibChangeNotify.cs
- StringExpressionSet.cs
- AffineTransform3D.cs
- KeyNotFoundException.cs
- Utils.cs
- SafeNativeMethods.cs
- BitmapEffectvisualstate.cs
- shaperfactory.cs
- XmlNodeChangedEventArgs.cs
- PhotoPrintingIntent.cs
- SqlCacheDependency.cs
- AttachedPropertyMethodSelector.cs
- Membership.cs
- COM2FontConverter.cs
- Int64KeyFrameCollection.cs
- AttributeEmitter.cs
- InputLanguageManager.cs
- TraceShell.cs
- TargetException.cs
- MemoryStream.cs
- WorkflowPersistenceService.cs
- DataPagerFieldCommandEventArgs.cs
- StringValidatorAttribute.cs
- IgnoreSection.cs
- SafeCryptHandles.cs
- ContainerUtilities.cs
- Base64WriteStateInfo.cs
- Fonts.cs
- relpropertyhelper.cs
- TreeNodeBindingCollection.cs
- MultilineStringConverter.cs
- ValidateNames.cs
- WindowsTokenRoleProvider.cs
- PhysicalOps.cs
- SqlNotificationEventArgs.cs
- XmlUnspecifiedAttribute.cs
- UrlAuthFailureHandler.cs
- OdbcConnection.cs
- TypeDependencyAttribute.cs
- SystemTcpStatistics.cs
- UnionCodeGroup.cs
- StrokeNodeOperations.cs
- ClientProxyGenerator.cs
- TileBrush.cs
- SQLInt16.cs
- PropertyInfo.cs
- UnknownBitmapDecoder.cs
- SkinBuilder.cs
- Helpers.cs
- DocumentSequenceHighlightLayer.cs
- InputChannelAcceptor.cs
- TransformerInfo.cs
- HtmlTextBoxAdapter.cs
- ControlParameter.cs
- DateTimeValueSerializerContext.cs
- PrintDialogDesigner.cs
- HttpDictionary.cs
- SegmentInfo.cs
- TreeIterator.cs
- mactripleDES.cs
- Visitor.cs
- DocumentationServerProtocol.cs
- Button.cs
- CacheOutputQuery.cs
- TrackingServices.cs
- XmlRawWriter.cs
- XmlSchemaAppInfo.cs
- StyleBamlTreeBuilder.cs
- XmlWriterDelegator.cs
- SpellerStatusTable.cs
- DropTarget.cs
- Rijndael.cs
- HexParser.cs
- DbUpdateCommandTree.cs
- TextTreeTextBlock.cs
- CodeParameterDeclarationExpressionCollection.cs
- DefaultAsyncDataDispatcher.cs
- ConstraintCollection.cs
- TextAutomationPeer.cs
- MatrixAnimationBase.cs