Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Base / System / ComponentModel / SortDescription.cs / 1305600 / SortDescription.cs
//---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: Defines property and direction to sort. // // See spec at http://avalon/connecteddata/M5%20Specs/IDataCollection.mht // // History: // 06/02/2003 : [....] - Created // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Windows; // SR using MS.Internal.WindowsBase; namespace System.ComponentModel { ////// Defines a property and direction to sort a list by. /// public struct SortDescription { //----------------------------------------------------- // // Public Constructors // //----------------------------------------------------- #region Public Constructors ////// Create a sort description. /// /// Property to sort by /// Specifies the direction of sort operation ///direction is not a valid value for ListSortDirection public SortDescription(string propertyName, ListSortDirection direction) { if (direction != ListSortDirection.Ascending && direction != ListSortDirection.Descending) throw new InvalidEnumArgumentException("direction", (int)direction, typeof(ListSortDirection)); _propertyName = propertyName; _direction = direction; _sealed = false; } #endregion Public Constructors //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region Public Properties ////// Property name to sort by. /// public string PropertyName { get { return _propertyName; } set { if (_sealed) throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SortDescription")); _propertyName = value; } } ////// Sort direction. /// public ListSortDirection Direction { get { return _direction; } set { if (_sealed) throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SortDescription")); if (value < ListSortDirection.Ascending || value > ListSortDirection.Descending) throw new InvalidEnumArgumentException("value", (int) value, typeof(ListSortDirection)); _direction = value; } } ////// Returns true if the SortDescription is in use (sealed). /// public bool IsSealed { get { return _sealed; } } #endregion Public Properties //------------------------------------------------------ // // Public methods // //------------------------------------------------------ #region Public Methods ///Override of Object.Equals public override bool Equals(object obj) { return (obj is SortDescription) ? (this == (SortDescription)obj) : false; } ///Equality operator for SortDescription. public static bool operator==(SortDescription sd1, SortDescription sd2) { return sd1.PropertyName == sd2.PropertyName && sd1.Direction == sd2.Direction; } ///Inequality operator for SortDescription. public static bool operator!=(SortDescription sd1, SortDescription sd2) { return !(sd1 == sd2); } ///Override of Object.GetHashCode public override int GetHashCode() { int result = Direction.GetHashCode(); if (PropertyName != null) { result = unchecked(PropertyName.GetHashCode() + result); } return result; } #endregion Public Methods //----------------------------------------------------- // // Internal methods // //------------------------------------------------------ #region Internal Methods internal void Seal() { _sealed = true; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields private string _propertyName; private ListSortDirection _direction; bool _sealed; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. //---------------------------------------------------------------------------- // //// Copyright (C) 2003 by Microsoft Corporation. All rights reserved. // // // // Description: Defines property and direction to sort. // // See spec at http://avalon/connecteddata/M5%20Specs/IDataCollection.mht // // History: // 06/02/2003 : [....] - Created // //--------------------------------------------------------------------------- using System; using System.ComponentModel; using System.Windows; // SR using MS.Internal.WindowsBase; namespace System.ComponentModel { ////// Defines a property and direction to sort a list by. /// public struct SortDescription { //----------------------------------------------------- // // Public Constructors // //----------------------------------------------------- #region Public Constructors ////// Create a sort description. /// /// Property to sort by /// Specifies the direction of sort operation ///direction is not a valid value for ListSortDirection public SortDescription(string propertyName, ListSortDirection direction) { if (direction != ListSortDirection.Ascending && direction != ListSortDirection.Descending) throw new InvalidEnumArgumentException("direction", (int)direction, typeof(ListSortDirection)); _propertyName = propertyName; _direction = direction; _sealed = false; } #endregion Public Constructors //------------------------------------------------------ // // Public Properties // //----------------------------------------------------- #region Public Properties ////// Property name to sort by. /// public string PropertyName { get { return _propertyName; } set { if (_sealed) throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SortDescription")); _propertyName = value; } } ////// Sort direction. /// public ListSortDirection Direction { get { return _direction; } set { if (_sealed) throw new InvalidOperationException(SR.Get(SRID.CannotChangeAfterSealed, "SortDescription")); if (value < ListSortDirection.Ascending || value > ListSortDirection.Descending) throw new InvalidEnumArgumentException("value", (int) value, typeof(ListSortDirection)); _direction = value; } } ////// Returns true if the SortDescription is in use (sealed). /// public bool IsSealed { get { return _sealed; } } #endregion Public Properties //------------------------------------------------------ // // Public methods // //------------------------------------------------------ #region Public Methods ///Override of Object.Equals public override bool Equals(object obj) { return (obj is SortDescription) ? (this == (SortDescription)obj) : false; } ///Equality operator for SortDescription. public static bool operator==(SortDescription sd1, SortDescription sd2) { return sd1.PropertyName == sd2.PropertyName && sd1.Direction == sd2.Direction; } ///Inequality operator for SortDescription. public static bool operator!=(SortDescription sd1, SortDescription sd2) { return !(sd1 == sd2); } ///Override of Object.GetHashCode public override int GetHashCode() { int result = Direction.GetHashCode(); if (PropertyName != null) { result = unchecked(PropertyName.GetHashCode() + result); } return result; } #endregion Public Methods //----------------------------------------------------- // // Internal methods // //------------------------------------------------------ #region Internal Methods internal void Seal() { _sealed = true; } #endregion Internal Methods //----------------------------------------------------- // // Private Fields // //----------------------------------------------------- #region Private Fields private string _propertyName; private ListSortDirection _direction; bool _sealed; #endregion Private Fields } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- OpenFileDialog.cs
- StrokeNodeOperations.cs
- TimerEventSubscription.cs
- ObjectStateEntry.cs
- ViewPort3D.cs
- AccessedThroughPropertyAttribute.cs
- HashAlgorithm.cs
- RSAPKCS1KeyExchangeDeformatter.cs
- TypeSchema.cs
- UnsafeNativeMethodsTablet.cs
- DayRenderEvent.cs
- ConnectionsZone.cs
- PropertyDescriptor.cs
- GridViewCommandEventArgs.cs
- HttpFileCollection.cs
- TypeConverterHelper.cs
- httpstaticobjectscollection.cs
- RegexStringValidatorAttribute.cs
- FillRuleValidation.cs
- JsonEncodingStreamWrapper.cs
- XmlSchema.cs
- X509SecurityToken.cs
- AssemblyHash.cs
- CompositeControl.cs
- OrthographicCamera.cs
- TextTrailingCharacterEllipsis.cs
- UpdateExpressionVisitor.cs
- Mutex.cs
- ProtocolViolationException.cs
- FixUpCollection.cs
- NullReferenceException.cs
- ContextStack.cs
- RelationshipType.cs
- IdentityManager.cs
- WindowsEditBoxRange.cs
- PrimaryKeyTypeConverter.cs
- Rotation3DKeyFrameCollection.cs
- DSACryptoServiceProvider.cs
- Win32KeyboardDevice.cs
- KeyedPriorityQueue.cs
- NameGenerator.cs
- DSACryptoServiceProvider.cs
- MetadataArtifactLoaderComposite.cs
- ConstraintStruct.cs
- DefaultPrintController.cs
- ProxyWebPart.cs
- ProfileSettingsCollection.cs
- CheckoutException.cs
- BufferBuilder.cs
- FontStyle.cs
- URIFormatException.cs
- TextComposition.cs
- Type.cs
- RegexWriter.cs
- CalendarAutoFormat.cs
- Validator.cs
- LambdaCompiler.Lambda.cs
- LinkClickEvent.cs
- UndoEngine.cs
- BatchStream.cs
- Point3DValueSerializer.cs
- DynamicILGenerator.cs
- sqlcontext.cs
- XdrBuilder.cs
- SetState.cs
- XmlDictionaryReaderQuotas.cs
- CustomPopupPlacement.cs
- PeerNameRecord.cs
- HostedElements.cs
- WebPartMenu.cs
- SchemaDeclBase.cs
- ToolConsole.cs
- MailAddressCollection.cs
- DataSvcMapFileSerializer.cs
- UxThemeWrapper.cs
- MediaElement.cs
- UrlPath.cs
- ValueUtilsSmi.cs
- XNameTypeConverter.cs
- HexParser.cs
- SByteStorage.cs
- StandardBindingElement.cs
- DataGridViewRowPrePaintEventArgs.cs
- TextPatternIdentifiers.cs
- XmlTextReaderImpl.cs
- EntityDataSourceContainerNameConverter.cs
- EntityDesignerBuildProvider.cs
- xmlfixedPageInfo.cs
- ResourceDescriptionAttribute.cs
- PaintValueEventArgs.cs
- ScalarConstant.cs
- InvalidDataContractException.cs
- CheckBoxAutomationPeer.cs
- PageEventArgs.cs
- ISO2022Encoding.cs
- RectConverter.cs
- ProfileGroupSettings.cs
- base64Transforms.cs
- MultilineStringConverter.cs
- Int32CollectionValueSerializer.cs