Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / wpf / src / Base / System / ComponentModel / SortDescription.cs / 2 / 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
- StrokeCollection2.cs
- Operand.cs
- fixedPageContentExtractor.cs
- ConnectionPoint.cs
- WebBrowserContainer.cs
- HttpRuntime.cs
- FloaterParaClient.cs
- XmlRawWriterWrapper.cs
- StylusPointPropertyInfo.cs
- BaseValidatorDesigner.cs
- OletxCommittableTransaction.cs
- ToolTip.cs
- DataGrid.cs
- CroppedBitmap.cs
- GradientBrush.cs
- CompModSwitches.cs
- SurrogateSelector.cs
- DbParameterCollection.cs
- ExpressionVisitorHelpers.cs
- InstancePersistenceCommand.cs
- PasswordRecoveryAutoFormat.cs
- GB18030Encoding.cs
- DispatcherOperation.cs
- DataGridViewCellParsingEventArgs.cs
- TemplateAction.cs
- Annotation.cs
- Authorization.cs
- MobileControlBuilder.cs
- Section.cs
- RoutedCommand.cs
- TextDataBindingHandler.cs
- PerfCounterSection.cs
- FlowDocumentPaginator.cs
- DbBuffer.cs
- PersianCalendar.cs
- KeyBinding.cs
- HttpModuleCollection.cs
- Menu.cs
- HierarchicalDataBoundControl.cs
- CustomWebEventKey.cs
- AlphaSortedEnumConverter.cs
- Propagator.ExtentPlaceholderCreator.cs
- VisualBasicSettings.cs
- HttpCapabilitiesBase.cs
- ViewLoader.cs
- Transform3DCollection.cs
- BinaryUtilClasses.cs
- PasswordValidationException.cs
- ContainerParaClient.cs
- CommandHelpers.cs
- StandardCommands.cs
- HtmlInputRadioButton.cs
- MediaPlayerState.cs
- IdentityHolder.cs
- ClientOptions.cs
- PeerCollaborationPermission.cs
- CounterSetInstanceCounterDataSet.cs
- SerTrace.cs
- WinFormsSpinner.cs
- WindowsFormsHelpers.cs
- WebPartDeleteVerb.cs
- Stack.cs
- ObfuscateAssemblyAttribute.cs
- PointLight.cs
- WebMessageEncoderFactory.cs
- _SslState.cs
- AxHostDesigner.cs
- AttachedProperty.cs
- ToolStripOverflow.cs
- StreamInfo.cs
- HostVisual.cs
- SelectedDatesCollection.cs
- ReadOnlyPermissionSet.cs
- InputChannelBinder.cs
- RemotingServices.cs
- ButtonFieldBase.cs
- AppDomainAttributes.cs
- Operator.cs
- HMACSHA384.cs
- SqlFunctionAttribute.cs
- ObjectItemAttributeAssemblyLoader.cs
- CheckBoxDesigner.cs
- XmlNodeChangedEventArgs.cs
- Utils.cs
- TypeLoadException.cs
- RegexGroupCollection.cs
- PassportIdentity.cs
- ConnectionManagementElement.cs
- securestring.cs
- Delay.cs
- BookmarkManager.cs
- SafeNativeMethodsCLR.cs
- DodSequenceMerge.cs
- SmiTypedGetterSetter.cs
- DataGridViewCellStyleBuilderDialog.cs
- PtsHost.cs
- RectangleConverter.cs
- Int16.cs
- COAUTHINFO.cs
- RangeValuePattern.cs