Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / wpf / src / Base / System / ComponentModel / SortDescription.cs / 1 / 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 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 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
- TaskExtensions.cs
- DataGridViewCellConverter.cs
- ExpressionConverter.cs
- FacetEnabledSchemaElement.cs
- serverconfig.cs
- SqlBooleanizer.cs
- x509utils.cs
- StoreItemCollection.cs
- validationstate.cs
- HttpsTransportBindingElement.cs
- SystemGatewayIPAddressInformation.cs
- IEnumerable.cs
- RelationshipEndCollection.cs
- XmlBinaryReaderSession.cs
- DialogResultConverter.cs
- CryptoKeySecurity.cs
- mactripleDES.cs
- WebPartTransformerAttribute.cs
- WebBrowserEvent.cs
- InheritanceContextHelper.cs
- IgnoreDeviceFilterElementCollection.cs
- DBCSCodePageEncoding.cs
- AssemblyBuilder.cs
- Size3DValueSerializer.cs
- HttpModuleCollection.cs
- DataSet.cs
- DurableTimerExtension.cs
- GlyphCache.cs
- datacache.cs
- SizeAnimationBase.cs
- StaticTextPointer.cs
- DetailsViewRowCollection.cs
- MulticastDelegate.cs
- ToolBarButton.cs
- DataGridItemCollection.cs
- SqlConnectionHelper.cs
- WindowsSlider.cs
- _ListenerResponseStream.cs
- SqlGenerator.cs
- CodeTypeReferenceCollection.cs
- HtmlTableCell.cs
- webeventbuffer.cs
- CallSiteBinder.cs
- ParentUndoUnit.cs
- HttpGetProtocolImporter.cs
- StylusEditingBehavior.cs
- InstanceKeyView.cs
- Exceptions.cs
- Unit.cs
- NumberFunctions.cs
- DiagnosticTraceSource.cs
- ColumnHeader.cs
- Int16KeyFrameCollection.cs
- SqlUserDefinedTypeAttribute.cs
- MimeTypeMapper.cs
- CustomActivityDesigner.cs
- ConfigXmlText.cs
- MouseButton.cs
- CombinedGeometry.cs
- DataException.cs
- DockAndAnchorLayout.cs
- HtmlObjectListAdapter.cs
- RequiredAttributeAttribute.cs
- LookupBindingPropertiesAttribute.cs
- InternalSafeNativeMethods.cs
- ZipIOCentralDirectoryFileHeader.cs
- CatalogPartChrome.cs
- Int16AnimationBase.cs
- XmlEnumAttribute.cs
- NumberSubstitution.cs
- TraceHandlerErrorFormatter.cs
- DataGrid.cs
- Roles.cs
- PerformanceCounterLib.cs
- SerializationSectionGroup.cs
- TreeNodeCollection.cs
- SQLConvert.cs
- TransformCollection.cs
- ScaleTransform3D.cs
- CalendarDataBindingHandler.cs
- Viewport3DAutomationPeer.cs
- XmlSchemaIdentityConstraint.cs
- TypeLoadException.cs
- DataGridViewCellErrorTextNeededEventArgs.cs
- WebPartTransformerCollection.cs
- DataGridColumnHeaderCollection.cs
- _Connection.cs
- EntityViewGenerationConstants.cs
- SR.cs
- Guid.cs
- URL.cs
- DSACryptoServiceProvider.cs
- XmlAggregates.cs
- LifetimeServices.cs
- InheritanceRules.cs
- UrlAuthorizationModule.cs
- SoapProtocolImporter.cs
- SamlConstants.cs
- SurrogateSelector.cs
- dbenumerator.cs