Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWeb / Server / System / Data / Services / ExpandSegment.cs / 1407647 / ExpandSegment.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a description of a segment in an $expand query option // for a WCF Data Service. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services { #region Namespaces. using System; using System.Collections.Generic; using System.Data.Services.Providers; using System.Diagnostics; using System.Linq.Expressions; #endregion Namespaces. ////// Provides a description of a segment in an $expand query option for a WCF Data Service. /// ////// INTERNAL /// Expand providers may replace segments to indicate a different expansion shape. However, they are /// unable to set the MaxResultsExpected. The value for the instances created by external providers /// will always be Int32.MaxValue, but the value enforced by the serializers will be the one declared /// by the data service in the configuration. /// /// When the configuration supports a more granular value, we should overload the constructor to make /// the MaxResultsExpected property settable as well. /// [DebuggerDisplay("ExpandSegment ({name},Filter={filter})]")] public class ExpandSegment { #region Private fields. ///Container to which the segment belongs; possibly null. private readonly ResourceSetWrapper container; ///Filter expression for this segment on an $expand path. private readonly Expression filter; ///Name for this segment on an $expand path. private readonly string name; ///Property being expanded. private readonly ResourceProperty expandedProperty; ////// The maximum number of results expected for this property; Int32.MaxValue if no limit is expected. /// private readonly int maxResultsExpected; ///Collection of ordering information for this segment, used for paging private readonly OrderingInfo orderingInfo; #endregion Private fields. #region Constructors. ///Initializes a new /// Segment name. /// Filter expression for segment, possibly null. public ExpandSegment(string name, Expression filter) : this(name, filter, Int32.MaxValue, null, null, null) { } ///instance. Initializes a new /// Segment name. /// Filter expression for segment, possibly null. /// /// Expand providers may choose to return at most MaxResultsExpected + 1 elements to allow the /// data service to detect a failure to meet this constraint. /// /// Container to which the segment belongs; possibly null. /// Property expanded by this expand segment /// Collection of ordering information for this segment, used for paging internal ExpandSegment( string name, Expression filter, int maxResultsExpected, ResourceSetWrapper container, ResourceProperty expandedProperty, OrderingInfo orderingInfo) { WebUtil.CheckArgumentNull(name, "name"); CheckFilterType(filter); this.name = name; this.filter = filter; this.container = container; this.maxResultsExpected = maxResultsExpected; this.expandedProperty = expandedProperty; this.orderingInfo = orderingInfo; } #endregion Constructors. #region Public properties. ///instance. Filter expression for this segment on an $expand path. public Expression Filter { get { return this.filter; } } ///Whether this segment has a filter. public bool HasFilter { get { return this.Filter != null; } } ////// The maximum number of results expected for this property; Int32.MaxValue if no limit is expected. /// ////// Expand providers may choose to return at most MaxResultsExpected + 1 elements to allow the /// data service to detect a failure to meet this constraint. /// public int MaxResultsExpected { get { return this.maxResultsExpected; } } ///Name for this segment on an $expand path. public string Name { get { return this.name; } } ///Property being expanded. public ResourceProperty ExpandedProperty { get { return this.expandedProperty; } } ///Collection of ordering information for this segment, used for paging internal OrderingInfo OrderingInfo { get { return this.orderingInfo; } } #endregion Public properties. #region Internal properties. ///Gets the container to which this segment belongs; possibly null. internal ResourceSetWrapper Container { get { return this.container; } } #endregion Internal properties. #region Public methods. ///Checks whether any segments in the specified /// Path with segments to check. ///have a filter. true if any of the segments in public static bool PathHasFilter(IEnumerablehas a filter; false otherwise. path) { WebUtil.CheckArgumentNull(path, "path"); foreach (ExpandSegment segment in path) { if (segment.HasFilter) { return true; } } return false; } #endregion Public methods. #region Private methods. /// Checks that the specified filter is of the right type. /// Filter to check. private static void CheckFilterType(Expression filter) { if (filter == null) { return; } if (filter.NodeType != ExpressionType.Lambda) { throw new ArgumentException(Strings.ExpandSegment_FilterShouldBeLambda(filter.NodeType), "filter"); } LambdaExpression lambda = (LambdaExpression)filter; if (lambda.Body.Type != typeof(bool) && lambda.Body.Type != typeof(bool?)) { throw new ArgumentException( Strings.ExpandSegment_FilterBodyShouldReturnBool(lambda.Body.Type), "filter"); } if (lambda.Parameters.Count != 1) { throw new ArgumentException( Strings.ExpandSegment_FilterBodyShouldTakeOneParameter(lambda.Parameters.Count), "filter"); } } #endregion Private methods. } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // //// Provides a description of a segment in an $expand query option // for a WCF Data Service. // // // @owner [....] //--------------------------------------------------------------------- namespace System.Data.Services { #region Namespaces. using System; using System.Collections.Generic; using System.Data.Services.Providers; using System.Diagnostics; using System.Linq.Expressions; #endregion Namespaces. ////// Provides a description of a segment in an $expand query option for a WCF Data Service. /// ////// INTERNAL /// Expand providers may replace segments to indicate a different expansion shape. However, they are /// unable to set the MaxResultsExpected. The value for the instances created by external providers /// will always be Int32.MaxValue, but the value enforced by the serializers will be the one declared /// by the data service in the configuration. /// /// When the configuration supports a more granular value, we should overload the constructor to make /// the MaxResultsExpected property settable as well. /// [DebuggerDisplay("ExpandSegment ({name},Filter={filter})]")] public class ExpandSegment { #region Private fields. ///Container to which the segment belongs; possibly null. private readonly ResourceSetWrapper container; ///Filter expression for this segment on an $expand path. private readonly Expression filter; ///Name for this segment on an $expand path. private readonly string name; ///Property being expanded. private readonly ResourceProperty expandedProperty; ////// The maximum number of results expected for this property; Int32.MaxValue if no limit is expected. /// private readonly int maxResultsExpected; ///Collection of ordering information for this segment, used for paging private readonly OrderingInfo orderingInfo; #endregion Private fields. #region Constructors. ///Initializes a new /// Segment name. /// Filter expression for segment, possibly null. public ExpandSegment(string name, Expression filter) : this(name, filter, Int32.MaxValue, null, null, null) { } ///instance. Initializes a new /// Segment name. /// Filter expression for segment, possibly null. /// /// Expand providers may choose to return at most MaxResultsExpected + 1 elements to allow the /// data service to detect a failure to meet this constraint. /// /// Container to which the segment belongs; possibly null. /// Property expanded by this expand segment /// Collection of ordering information for this segment, used for paging internal ExpandSegment( string name, Expression filter, int maxResultsExpected, ResourceSetWrapper container, ResourceProperty expandedProperty, OrderingInfo orderingInfo) { WebUtil.CheckArgumentNull(name, "name"); CheckFilterType(filter); this.name = name; this.filter = filter; this.container = container; this.maxResultsExpected = maxResultsExpected; this.expandedProperty = expandedProperty; this.orderingInfo = orderingInfo; } #endregion Constructors. #region Public properties. ///instance. Filter expression for this segment on an $expand path. public Expression Filter { get { return this.filter; } } ///Whether this segment has a filter. public bool HasFilter { get { return this.Filter != null; } } ////// The maximum number of results expected for this property; Int32.MaxValue if no limit is expected. /// ////// Expand providers may choose to return at most MaxResultsExpected + 1 elements to allow the /// data service to detect a failure to meet this constraint. /// public int MaxResultsExpected { get { return this.maxResultsExpected; } } ///Name for this segment on an $expand path. public string Name { get { return this.name; } } ///Property being expanded. public ResourceProperty ExpandedProperty { get { return this.expandedProperty; } } ///Collection of ordering information for this segment, used for paging internal OrderingInfo OrderingInfo { get { return this.orderingInfo; } } #endregion Public properties. #region Internal properties. ///Gets the container to which this segment belongs; possibly null. internal ResourceSetWrapper Container { get { return this.container; } } #endregion Internal properties. #region Public methods. ///Checks whether any segments in the specified /// Path with segments to check. ///have a filter. true if any of the segments in public static bool PathHasFilter(IEnumerablehas a filter; false otherwise. path) { WebUtil.CheckArgumentNull(path, "path"); foreach (ExpandSegment segment in path) { if (segment.HasFilter) { return true; } } return false; } #endregion Public methods. #region Private methods. /// Checks that the specified filter is of the right type. /// Filter to check. private static void CheckFilterType(Expression filter) { if (filter == null) { return; } if (filter.NodeType != ExpressionType.Lambda) { throw new ArgumentException(Strings.ExpandSegment_FilterShouldBeLambda(filter.NodeType), "filter"); } LambdaExpression lambda = (LambdaExpression)filter; if (lambda.Body.Type != typeof(bool) && lambda.Body.Type != typeof(bool?)) { throw new ArgumentException( Strings.ExpandSegment_FilterBodyShouldReturnBool(lambda.Body.Type), "filter"); } if (lambda.Parameters.Count != 1) { throw new ArgumentException( Strings.ExpandSegment_FilterBodyShouldTakeOneParameter(lambda.Parameters.Count), "filter"); } } #endregion Private methods. } } // 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
- PageParser.cs
- Freezable.cs
- ListItemsPage.cs
- XmlTextReaderImplHelpers.cs
- FontFaceLayoutInfo.cs
- CharacterHit.cs
- ModelVisual3D.cs
- BlockCollection.cs
- Propagator.ExtentPlaceholderCreator.cs
- EventWaitHandle.cs
- PublisherIdentityPermission.cs
- ActivityTrace.cs
- UnderstoodHeaders.cs
- PathSegmentCollection.cs
- ActionFrame.cs
- NodeInfo.cs
- TextReader.cs
- DataGridViewColumnHeaderCell.cs
- SignatureHelper.cs
- WebMessageEncoderFactory.cs
- SecurityCapabilities.cs
- VisualStyleRenderer.cs
- CryptoSession.cs
- ClientSettingsProvider.cs
- HttpRequest.cs
- HideDisabledControlAdapter.cs
- ExitEventArgs.cs
- AlternateView.cs
- SqlFlattener.cs
- XmlAggregates.cs
- Module.cs
- DateTime.cs
- HwndSubclass.cs
- PersonalizableAttribute.cs
- ConsumerConnectionPoint.cs
- GPStream.cs
- InstanceCreationEditor.cs
- ChildTable.cs
- CodeChecksumPragma.cs
- ProxyBuilder.cs
- ClassDataContract.cs
- TypeValidationEventArgs.cs
- NonSerializedAttribute.cs
- DataStreams.cs
- NamespaceExpr.cs
- CodeEntryPointMethod.cs
- DocumentSequenceHighlightLayer.cs
- SingleQueryOperator.cs
- invalidudtexception.cs
- ExitEventArgs.cs
- WindowsPrincipal.cs
- ImageDrawing.cs
- DirectionalLight.cs
- DataServiceKeyAttribute.cs
- CreateUserErrorEventArgs.cs
- SerializableAuthorizationContext.cs
- ScriptingRoleServiceSection.cs
- ButtonBaseAdapter.cs
- EmptyControlCollection.cs
- ParameterModifier.cs
- CustomSignedXml.cs
- ConnectionStringSettingsCollection.cs
- PersianCalendar.cs
- Vector3DCollection.cs
- ResourceExpression.cs
- SetUserLanguageRequest.cs
- StrongNameKeyPair.cs
- MessageVersionConverter.cs
- DialogWindow.cs
- XamlTypeWithExplicitNamespace.cs
- BadImageFormatException.cs
- Range.cs
- FeatureSupport.cs
- CryptoHandle.cs
- SqlCachedBuffer.cs
- DefaultAuthorizationContext.cs
- SingleResultAttribute.cs
- SqlNodeAnnotations.cs
- ContextBase.cs
- Line.cs
- SvcMapFileSerializer.cs
- _DynamicWinsockMethods.cs
- SimpleColumnProvider.cs
- XmlAggregates.cs
- BlockCollection.cs
- BitVec.cs
- ExceptionHandler.cs
- SchemaTypeEmitter.cs
- Storyboard.cs
- DocumentPageHost.cs
- SortedList.cs
- DodSequenceMerge.cs
- ConfigurationLocationCollection.cs
- DataReaderContainer.cs
- XmlSchemaGroupRef.cs
- Timer.cs
- System.Data.OracleClient_BID.cs
- GridItemCollection.cs
- SpecialFolderEnumConverter.cs
- CheckBox.cs