Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / SwitchCase.cs / 1305376 / SwitchCase.cs
/* **************************************************************************** * * Copyright (c) Microsoft Corporation. * * This source code is subject to terms and conditions of the Microsoft Public License. A * copy of the license can be found in the License.html file at the root of this distribution. If * you cannot locate the Microsoft Public License, please send an email to * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound * by the terms of the Microsoft Public License. * * You must not remove this notice, or any other, from this software. * * * ***************************************************************************/ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Dynamic.Utils; namespace System.Linq.Expressions { ////// Represents one case of a #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.SwitchCaseProxy))] #endif public sealed class SwitchCase { private readonly ReadOnlyCollection. /// _testValues; private readonly Expression _body; internal SwitchCase(Expression body, ReadOnlyCollection testValues) { _body = body; _testValues = testValues; } /// /// Gets the values of this case. This case is selected for execution when the public ReadOnlyCollectionmatches any of these values. /// TestValues { get { return _testValues; } } /// /// Gets the body of this case. /// public Expression Body { get { return _body; } } ////// Returns a ///that represents the current . /// A public override string ToString() { return ExpressionStringBuilder.SwitchCaseToString(this); } ///that represents the current . /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// /// Theproperty of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public SwitchCase Update(IEnumerabletestValues, Expression body) { if (testValues == TestValues && body == Body) { return this; } return Expression.SwitchCase(body, testValues); } } public partial class Expression { /// /// Creates a /// The body of the case. /// The test values of the case. ///SwitchCase for use in a. /// The created public static SwitchCase SwitchCase(Expression body, params Expression[] testValues) { return SwitchCase(body, (IEnumerableSwitchCase .)testValues); } /// /// Creates a /// The body of the case. /// The test values of the case. ///SwitchCase for use in a. /// The created public static SwitchCase SwitchCase(Expression body, IEnumerableSwitchCase .testValues) { RequiresCanRead(body, "body"); var values = testValues.ToReadOnly(); RequiresCanRead(values, "testValues"); ContractUtils.RequiresNotEmpty(values, "testValues"); return new SwitchCase(body, values); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. /* **************************************************************************** * * Copyright (c) Microsoft Corporation. * * This source code is subject to terms and conditions of the Microsoft Public License. A * copy of the license can be found in the License.html file at the root of this distribution. If * you cannot locate the Microsoft Public License, please send an email to * dlr@microsoft.com. By using this source code in any fashion, you are agreeing to be bound * by the terms of the Microsoft Public License. * * You must not remove this notice, or any other, from this software. * * * ***************************************************************************/ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Dynamic.Utils; namespace System.Linq.Expressions { /// /// Represents one case of a #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.SwitchCaseProxy))] #endif public sealed class SwitchCase { private readonly ReadOnlyCollection. /// _testValues; private readonly Expression _body; internal SwitchCase(Expression body, ReadOnlyCollection testValues) { _body = body; _testValues = testValues; } /// /// Gets the values of this case. This case is selected for execution when the public ReadOnlyCollectionmatches any of these values. /// TestValues { get { return _testValues; } } /// /// Gets the body of this case. /// public Expression Body { get { return _body; } } ////// Returns a ///that represents the current . /// A public override string ToString() { return ExpressionStringBuilder.SwitchCaseToString(this); } ///that represents the current . /// Creates a new expression that is like this one, but using the /// supplied children. If all of the children are the same, it will /// return this expression. /// /// Theproperty of the result. /// The property of the result. /// This expression if no children changed, or an expression with the updated children. public SwitchCase Update(IEnumerabletestValues, Expression body) { if (testValues == TestValues && body == Body) { return this; } return Expression.SwitchCase(body, testValues); } } public partial class Expression { /// /// Creates a /// The body of the case. /// The test values of the case. ///SwitchCase for use in a. /// The created public static SwitchCase SwitchCase(Expression body, params Expression[] testValues) { return SwitchCase(body, (IEnumerableSwitchCase .)testValues); } /// /// Creates a /// The body of the case. /// The test values of the case. ///SwitchCase for use in a. /// The created public static SwitchCase SwitchCase(Expression body, IEnumerableSwitchCase .testValues) { RequiresCanRead(body, "body"); var values = testValues.ToReadOnly(); RequiresCanRead(values, "testValues"); ContractUtils.RequiresNotEmpty(values, "testValues"); return new SwitchCase(body, values); } } } // 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
- PropertyTab.cs
- VisualStyleElement.cs
- KerberosTicketHashIdentifierClause.cs
- OLEDB_Enum.cs
- MetadataException.cs
- HostingEnvironmentSection.cs
- EncoderReplacementFallback.cs
- GroupDescription.cs
- OutputScope.cs
- Array.cs
- MissingMethodException.cs
- ObjectMemberMapping.cs
- UdpTransportSettings.cs
- QilGenerator.cs
- ToolStripDropDownItem.cs
- BaseParagraph.cs
- WebPartActionVerb.cs
- ValueConversionAttribute.cs
- DragDrop.cs
- BlurBitmapEffect.cs
- DataGridPagerStyle.cs
- ControlSerializer.cs
- WorkflowApplicationCompletedException.cs
- MsmqBindingElementBase.cs
- DynamicQueryStringParameter.cs
- GenerateTemporaryTargetAssembly.cs
- TreeNodeBindingDepthConverter.cs
- DefaultBindingPropertyAttribute.cs
- FixedBufferAttribute.cs
- Switch.cs
- Point3DAnimation.cs
- StyleCollection.cs
- Rect.cs
- System.Data_BID.cs
- ObjectTokenCategory.cs
- Image.cs
- EntityClientCacheEntry.cs
- LinqDataSource.cs
- CriticalHandle.cs
- TextBlock.cs
- HtmlHistory.cs
- ValidateNames.cs
- LabelTarget.cs
- ForceCopyBuildProvider.cs
- CategoriesDocumentFormatter.cs
- BezierSegment.cs
- ReferenceConverter.cs
- SpeechSynthesizer.cs
- DetailsViewInsertedEventArgs.cs
- PageStatePersister.cs
- SaveFileDialog.cs
- Constants.cs
- QueryContinueDragEvent.cs
- OrthographicCamera.cs
- CheckBoxFlatAdapter.cs
- VersionedStreamOwner.cs
- ComplusEndpointConfigContainer.cs
- IssuedTokenClientCredential.cs
- MulticastNotSupportedException.cs
- WindowsEditBox.cs
- Baml2006ReaderFrame.cs
- DesignerActionVerbList.cs
- Block.cs
- TreeViewEvent.cs
- TdsParserHelperClasses.cs
- WorkflowFileItem.cs
- InputMethod.cs
- AssociationSetMetadata.cs
- AuthenticationServiceManager.cs
- DefaultMemberAttribute.cs
- XmlNodeChangedEventArgs.cs
- DataGridViewRowConverter.cs
- SiteMapPath.cs
- LinkConverter.cs
- Privilege.cs
- DropShadowBitmapEffect.cs
- SourceFilter.cs
- PropertyValueUIItem.cs
- CompositeDuplexBindingElement.cs
- RadialGradientBrush.cs
- ByeOperation11AsyncResult.cs
- RequestCachePolicyConverter.cs
- SymbolDocumentInfo.cs
- LineInfo.cs
- DataTableNewRowEvent.cs
- NativeWrapper.cs
- SqlClientFactory.cs
- Processor.cs
- PropertyPushdownHelper.cs
- SQLDouble.cs
- IriParsingElement.cs
- DocumentXPathNavigator.cs
- TreeViewImageIndexConverter.cs
- NativeMethods.cs
- CharKeyFrameCollection.cs
- MasterPageParser.cs
- DataGridViewLinkColumn.cs
- InputManager.cs
- ColorConverter.cs
- ResourceExpressionEditorSheet.cs