Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / Web / Configuration / RuleInfoComparer.cs / 1305376 / RuleInfoComparer.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.ComponentModel; using System.Web.Hosting; using System.Web.Util; using System.Web.Configuration; using System.Web.Management; using System.Web.Compilation; // // This class is used to compare two RuleInfo object. Basically, the array list // will be sorted based on class hierachical order. The smaller the value, the // more nearer the class is to the root (WebBaseEvent), in a class inheritance sense. // // On the other hand, if x > y, it means x is NOT a parent class of y. // // The array is sorted in this way so that if we want to find out the config setting of // an event class x, we start searching in a decreasing order, and the first entry (E) // that satifies the test: if (x is E), then we find the right settings for x. // // BTW, this is just a trick to save me from writing too much code. A n-node tree // method is faster, but I was too lazy. // internal class RuleInfoComparer : IComparer{ public int Compare(object x, object y) { int res; Type xType = ((HealthMonitoringSectionHelper.RuleInfo)x)._eventMappingSettings.RealType; Type yType = ((HealthMonitoringSectionHelper.RuleInfo)y)._eventMappingSettings.RealType; if (xType.Equals(yType)) { res = 0; } else if (xType.IsSubclassOf(yType)) { res = 1; } else if (yType.IsSubclassOf(xType)) { res = -1; } else { // If they're unrelated, we can't return 0 because it // will confuse the sorting method. // We can return 1 or -1, but it must be consistent. return String.Compare(xType.ToString(), yType.ToString(), StringComparison.Ordinal); } Debug.Trace("RuleInfoComparer", "xType=" + xType.ToString() + "; yType=" + yType.ToString() + "; res=" + res); return res; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.Configuration { using System; using System.Xml; using System.Configuration; using System.Collections.Specialized; using System.Collections; using System.Globalization; using System.IO; using System.Text; using System.ComponentModel; using System.Web.Hosting; using System.Web.Util; using System.Web.Configuration; using System.Web.Management; using System.Web.Compilation; // // This class is used to compare two RuleInfo object. Basically, the array list // will be sorted based on class hierachical order. The smaller the value, the // more nearer the class is to the root (WebBaseEvent), in a class inheritance sense. // // On the other hand, if x > y, it means x is NOT a parent class of y. // // The array is sorted in this way so that if we want to find out the config setting of // an event class x, we start searching in a decreasing order, and the first entry (E) // that satifies the test: if (x is E), then we find the right settings for x. // // BTW, this is just a trick to save me from writing too much code. A n-node tree // method is faster, but I was too lazy. // internal class RuleInfoComparer : IComparer{ public int Compare(object x, object y) { int res; Type xType = ((HealthMonitoringSectionHelper.RuleInfo)x)._eventMappingSettings.RealType; Type yType = ((HealthMonitoringSectionHelper.RuleInfo)y)._eventMappingSettings.RealType; if (xType.Equals(yType)) { res = 0; } else if (xType.IsSubclassOf(yType)) { res = 1; } else if (yType.IsSubclassOf(xType)) { res = -1; } else { // If they're unrelated, we can't return 0 because it // will confuse the sorting method. // We can return 1 or -1, but it must be consistent. return String.Compare(xType.ToString(), yType.ToString(), StringComparison.Ordinal); } Debug.Trace("RuleInfoComparer", "xType=" + xType.ToString() + "; yType=" + yType.ToString() + "; res=" + res); return res; } } } // 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
- ProxySimple.cs
- WindowsStartMenu.cs
- UInt16Storage.cs
- WebPartActionVerb.cs
- StoragePropertyMapping.cs
- UnsafeNativeMethods.cs
- CFGGrammar.cs
- AttributeQuery.cs
- HtmlTextArea.cs
- EntityDataReader.cs
- ObjectTag.cs
- ResourceExpressionBuilder.cs
- NativeMethods.cs
- SemanticResolver.cs
- DynamicScriptObject.cs
- sitestring.cs
- DefaultSection.cs
- EmptyEnumerator.cs
- DataGridViewToolTip.cs
- GenericWebPart.cs
- ListenerSessionConnectionReader.cs
- BlurEffect.cs
- SoapDocumentMethodAttribute.cs
- BitmapSourceSafeMILHandle.cs
- CodeSubDirectory.cs
- UserCancellationException.cs
- MsmqBindingElementBase.cs
- RNGCryptoServiceProvider.cs
- WebPartEditorCancelVerb.cs
- ViewManager.cs
- SimpleRecyclingCache.cs
- AppDomainGrammarProxy.cs
- RegexTree.cs
- ScrollItemPattern.cs
- JsonServiceDocumentSerializer.cs
- DateTimeParse.cs
- FontSizeConverter.cs
- SamlAssertionKeyIdentifierClause.cs
- GorillaCodec.cs
- HtmlForm.cs
- TableRowGroup.cs
- TypedTableGenerator.cs
- StylusCaptureWithinProperty.cs
- XmlFormatWriterGenerator.cs
- DispatcherTimer.cs
- CodeCommentStatement.cs
- Rotation3DKeyFrameCollection.cs
- SymmetricKeyWrap.cs
- ConstantCheck.cs
- SystemResources.cs
- COAUTHINFO.cs
- CodeThrowExceptionStatement.cs
- EventDescriptorCollection.cs
- RewritingProcessor.cs
- TextTreeFixupNode.cs
- EntityConnection.cs
- TextServicesCompartmentContext.cs
- StyleCollection.cs
- SubMenuStyle.cs
- URIFormatException.cs
- SQLCharsStorage.cs
- MasterPageBuildProvider.cs
- ToolStripArrowRenderEventArgs.cs
- SrgsGrammar.cs
- TreeBuilder.cs
- XmlILIndex.cs
- SessionStateModule.cs
- ConfigurationUtility.cs
- ConsoleTraceListener.cs
- TrustLevel.cs
- WindowsListView.cs
- XmlSchemaObject.cs
- BooleanExpr.cs
- Int16.cs
- XsltContext.cs
- HtmlTitle.cs
- TextEmbeddedObject.cs
- SwitchElementsCollection.cs
- Thumb.cs
- EncryptedPackageFilter.cs
- Span.cs
- NotificationContext.cs
- DbQueryCommandTree.cs
- WCFBuildProvider.cs
- WorkerRequest.cs
- RoleBoolean.cs
- FileSystemWatcher.cs
- CustomSignedXml.cs
- DataSysAttribute.cs
- HttpClientCertificate.cs
- RootBrowserWindowAutomationPeer.cs
- Dynamic.cs
- WindowsSpinner.cs
- CodeExpressionCollection.cs
- DBNull.cs
- ProtocolsConfiguration.cs
- NamespaceCollection.cs
- ValueType.cs
- TextParagraphView.cs
- SignatureToken.cs