Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / LabelExpression.cs / 1305376 / LabelExpression.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.Diagnostics; namespace System.Linq.Expressions { ////// Represents a label, which can be placed in any #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.LabelExpressionProxy))] #endif public sealed class LabelExpression : Expression { private readonly Expression _defaultValue; private readonly LabelTarget _target; internal LabelExpression(LabelTarget label, Expression defaultValue) { _target = label; _defaultValue = defaultValue; } ///context. If /// it is jumped to, it will get the value provided by the corresponding /// . Otherwise, it gets the value in . If the /// equals System.Void, no value should be provided. /// /// Gets the static type of the expression that this ///represents. (Inherited from .) /// The public sealed override Type Type { get { return _target.Type; } } ///that represents the static type of the expression. /// Returns the node type of this ///. (Inherited from .) /// The public sealed override ExpressionType NodeType { get { return ExpressionType.Label; } } ///that represents this expression. /// The public LabelTarget Target { get { return _target; } } ///which this label is associated with. /// /// The value of the public Expression DefaultValue { get { return _defaultValue; } } ///when the label is reached through /// normal control flow (e.g. is not jumped to). /// /// Dispatches to the specific visit method for this node type. /// protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitLabel(this); } ////// 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 LabelExpression Update(LabelTarget target, Expression defaultValue) { if (target == Target && defaultValue == DefaultValue) { return this; } return Expression.Label(target, defaultValue); } } public partial class Expression { ////// Creates a /// Therepresenting a label with no default value. /// which this will be associated with. /// A public static LabelExpression Label(LabelTarget target) { return Label(target, null); } ///with no default value. /// Creates a /// Therepresenting a label with the given default value. /// which this will be associated with. /// The value of this when the label is reached through normal control flow. /// A public static LabelExpression Label(LabelTarget target, Expression defaultValue) { ValidateGoto(target, ref defaultValue, "label", "defaultValue"); return new LabelExpression(target, defaultValue); } } } // 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.Diagnostics; namespace System.Linq.Expressions { ///with the given default value. /// Represents a label, which can be placed in any #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.LabelExpressionProxy))] #endif public sealed class LabelExpression : Expression { private readonly Expression _defaultValue; private readonly LabelTarget _target; internal LabelExpression(LabelTarget label, Expression defaultValue) { _target = label; _defaultValue = defaultValue; } ///context. If /// it is jumped to, it will get the value provided by the corresponding /// . Otherwise, it gets the value in . If the /// equals System.Void, no value should be provided. /// /// Gets the static type of the expression that this ///represents. (Inherited from .) /// The public sealed override Type Type { get { return _target.Type; } } ///that represents the static type of the expression. /// Returns the node type of this ///. (Inherited from .) /// The public sealed override ExpressionType NodeType { get { return ExpressionType.Label; } } ///that represents this expression. /// The public LabelTarget Target { get { return _target; } } ///which this label is associated with. /// /// The value of the public Expression DefaultValue { get { return _defaultValue; } } ///when the label is reached through /// normal control flow (e.g. is not jumped to). /// /// Dispatches to the specific visit method for this node type. /// protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitLabel(this); } ////// 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 LabelExpression Update(LabelTarget target, Expression defaultValue) { if (target == Target && defaultValue == DefaultValue) { return this; } return Expression.Label(target, defaultValue); } } public partial class Expression { ////// Creates a /// Therepresenting a label with no default value. /// which this will be associated with. /// A public static LabelExpression Label(LabelTarget target) { return Label(target, null); } ///with no default value. /// Creates a /// Therepresenting a label with the given default value. /// which this will be associated with. /// The value of this when the label is reached through normal control flow. /// A public static LabelExpression Label(LabelTarget target, Expression defaultValue) { ValidateGoto(target, ref defaultValue, "label", "defaultValue"); return new LabelExpression(target, defaultValue); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.with the given default value.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- CorrelationTokenTypeConvertor.cs
- SecurityKeyIdentifierClause.cs
- ReliableMessagingVersionConverter.cs
- OleDbRowUpdatedEvent.cs
- XmlWrappingReader.cs
- SafeRightsManagementPubHandle.cs
- ValidationRuleCollection.cs
- ObjectStateEntry.cs
- GridViewSelectEventArgs.cs
- CodeTypeDeclarationCollection.cs
- Timeline.cs
- UnhandledExceptionEventArgs.cs
- SessionStateContainer.cs
- CodeTypeReference.cs
- FrameworkContentElementAutomationPeer.cs
- TextBlock.cs
- LinqDataSourceSelectEventArgs.cs
- TypeTypeConverter.cs
- PageStatePersister.cs
- CancellationTokenSource.cs
- Stacktrace.cs
- _SpnDictionary.cs
- EntityTypeEmitter.cs
- CheckedPointers.cs
- HtmlWindow.cs
- EncoderFallback.cs
- ConfigurationErrorsException.cs
- ExpressionVisitor.cs
- SqlBuffer.cs
- QilChoice.cs
- SymbolType.cs
- LogRestartAreaEnumerator.cs
- CacheChildrenQuery.cs
- QilInvokeEarlyBound.cs
- CodeCompileUnit.cs
- SystemBrushes.cs
- TableProviderWrapper.cs
- ActivityTypeCodeDomSerializer.cs
- DataGridViewSelectedRowCollection.cs
- DecoderExceptionFallback.cs
- FixedPage.cs
- FormsAuthenticationConfiguration.cs
- ConsumerConnectionPointCollection.cs
- RuntimeComponentFilter.cs
- PlatformCulture.cs
- ResourceAssociationType.cs
- NativeCppClassAttribute.cs
- RsaKeyIdentifierClause.cs
- DoubleKeyFrameCollection.cs
- BitStack.cs
- odbcmetadatafactory.cs
- Button.cs
- SqlCacheDependencyDatabase.cs
- _TransmitFileOverlappedAsyncResult.cs
- RSAPKCS1KeyExchangeFormatter.cs
- AesManaged.cs
- EventManager.cs
- PauseStoryboard.cs
- XmlBinaryReader.cs
- ExtensionWindow.cs
- DbReferenceCollection.cs
- InkCanvasSelectionAdorner.cs
- AudioLevelUpdatedEventArgs.cs
- Slider.cs
- Size.cs
- HtmlTernaryTree.cs
- MemoryStream.cs
- TypeUtils.cs
- WebHttpBehavior.cs
- BaseDataListPage.cs
- TableStyle.cs
- FontStyle.cs
- TransformerConfigurationWizardBase.cs
- LinqDataSourceSelectEventArgs.cs
- WebPartActionVerb.cs
- SerializationObjectManager.cs
- RewritingSimplifier.cs
- XPathAxisIterator.cs
- OleStrCAMarshaler.cs
- HttpCookieCollection.cs
- HGlobalSafeHandle.cs
- AsyncOperation.cs
- TextRenderer.cs
- MaskInputRejectedEventArgs.cs
- ScrollChrome.cs
- MinimizableAttributeTypeConverter.cs
- Material.cs
- SafeRightsManagementPubHandle.cs
- _FtpDataStream.cs
- ApplicationManager.cs
- UndoManager.cs
- LabelLiteral.cs
- SystemDiagnosticsSection.cs
- SqlInternalConnection.cs
- AstTree.cs
- GuidTagList.cs
- BaseCodeDomTreeGenerator.cs
- ListViewDeleteEventArgs.cs
- XmlNamespaceDeclarationsAttribute.cs
- DataGridViewCellToolTipTextNeededEventArgs.cs