Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / RuntimeVariablesExpression.cs / 1305376 / RuntimeVariablesExpression.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; using System.Runtime.CompilerServices; namespace System.Linq.Expressions { ////// An expression that provides runtime read/write access to variables. /// Needed to implement "eval" in some dynamic languages. /// Evaluates to an instance of #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.RuntimeVariablesExpressionProxy))] #endif public sealed class RuntimeVariablesExpression : Expression { private readonly ReadOnlyCollectionwhen executed. /// _variables; internal RuntimeVariablesExpression(ReadOnlyCollection variables) { _variables = variables; } /// /// Gets the static type of the expression that this ///represents. /// The public sealed override Type Type { get { return typeof(IRuntimeVariables); } } ///that represents the static type of the expression. /// Returns the node type of this Expression. Extension nodes should return /// ExpressionType.Extension when overriding this method. /// ///The public sealed override ExpressionType NodeType { get { return ExpressionType.RuntimeVariables; } } ///of the expression. /// The variables or parameters to which to provide runtime access. /// public ReadOnlyCollectionVariables { get { return _variables; } } /// /// Dispatches to the specific visit method for this node type. /// protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitRuntimeVariables(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. /// This expression if no children changed, or an expression with the updated children. public RuntimeVariablesExpression Update(IEnumerablevariables) { if (variables == Variables) { return this; } return Expression.RuntimeVariables(variables); } } public partial class Expression { /// /// Creates an instance of /// An array of. /// objects to use to populate the collection. /// An instance of public static RuntimeVariablesExpression RuntimeVariables(params ParameterExpression[] variables) { return RuntimeVariables((IEnumerablethat has the property equal to and the property set to the specified value. )variables); } /// /// Creates an instance of /// A collection of. /// objects to use to populate the collection. /// An instance of public static RuntimeVariablesExpression RuntimeVariables(IEnumerablethat has the property equal to and the property set to the specified value. variables) { ContractUtils.RequiresNotNull(variables, "variables"); var vars = variables.ToReadOnly(); for (int i = 0; i < vars.Count; i++) { Expression v = vars[i]; if (v == null) { throw new ArgumentNullException("variables[" + i + "]"); } } return new RuntimeVariablesExpression(vars); } } } // 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; using System.Runtime.CompilerServices; namespace System.Linq.Expressions { /// /// An expression that provides runtime read/write access to variables. /// Needed to implement "eval" in some dynamic languages. /// Evaluates to an instance of #if !SILVERLIGHT [DebuggerTypeProxy(typeof(Expression.RuntimeVariablesExpressionProxy))] #endif public sealed class RuntimeVariablesExpression : Expression { private readonly ReadOnlyCollectionwhen executed. /// _variables; internal RuntimeVariablesExpression(ReadOnlyCollection variables) { _variables = variables; } /// /// Gets the static type of the expression that this ///represents. /// The public sealed override Type Type { get { return typeof(IRuntimeVariables); } } ///that represents the static type of the expression. /// Returns the node type of this Expression. Extension nodes should return /// ExpressionType.Extension when overriding this method. /// ///The public sealed override ExpressionType NodeType { get { return ExpressionType.RuntimeVariables; } } ///of the expression. /// The variables or parameters to which to provide runtime access. /// public ReadOnlyCollectionVariables { get { return _variables; } } /// /// Dispatches to the specific visit method for this node type. /// protected internal override Expression Accept(ExpressionVisitor visitor) { return visitor.VisitRuntimeVariables(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. /// This expression if no children changed, or an expression with the updated children. public RuntimeVariablesExpression Update(IEnumerablevariables) { if (variables == Variables) { return this; } return Expression.RuntimeVariables(variables); } } public partial class Expression { /// /// Creates an instance of /// An array of. /// objects to use to populate the collection. /// An instance of public static RuntimeVariablesExpression RuntimeVariables(params ParameterExpression[] variables) { return RuntimeVariables((IEnumerablethat has the property equal to and the property set to the specified value. )variables); } /// /// Creates an instance of /// A collection of. /// objects to use to populate the collection. /// An instance of public static RuntimeVariablesExpression RuntimeVariables(IEnumerablethat has the property equal to and the property set to the specified value. variables) { ContractUtils.RequiresNotNull(variables, "variables"); var vars = variables.ToReadOnly(); for (int i = 0; i < vars.Count; i++) { Expression v = vars[i]; if (v == null) { throw new ArgumentNullException("variables[" + i + "]"); } } return new RuntimeVariablesExpression(vars); } } } // 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
- DeriveBytes.cs
- EventLogStatus.cs
- PcmConverter.cs
- LinqDataSourceContextEventArgs.cs
- XmlElementList.cs
- SplitterCancelEvent.cs
- StopStoryboard.cs
- RequestCachingSection.cs
- UnSafeCharBuffer.cs
- RuntimeWrappedException.cs
- MobileControlsSectionHelper.cs
- MsmqIntegrationMessageProperty.cs
- WebPartConnectVerb.cs
- Model3D.cs
- xsdvalidator.cs
- FixedBufferAttribute.cs
- SqlStatistics.cs
- FontSourceCollection.cs
- SupportsEventValidationAttribute.cs
- WebEventCodes.cs
- XmlCDATASection.cs
- FlowSwitchDesigner.xaml.cs
- AppDomainProtocolHandler.cs
- CompositeControlDesigner.cs
- PreDigestedSignedInfo.cs
- TrackBarRenderer.cs
- XmlException.cs
- ShimAsPublicXamlType.cs
- DispatcherEventArgs.cs
- Point4DValueSerializer.cs
- DataViewManager.cs
- ClientSettingsStore.cs
- IIS7UserPrincipal.cs
- OleStrCAMarshaler.cs
- PerfService.cs
- InstanceData.cs
- EntityDesignerUtils.cs
- UTF8Encoding.cs
- EncryptedType.cs
- AttributeEmitter.cs
- DefaultBinder.cs
- WebPartVerbCollection.cs
- EncoderParameters.cs
- XPathNodeInfoAtom.cs
- StaticSiteMapProvider.cs
- StrongTypingException.cs
- DataColumnMapping.cs
- ArrayTypeMismatchException.cs
- ObjectListGeneralPage.cs
- PropertyDescriptorCollection.cs
- EventPropertyMap.cs
- OdbcError.cs
- Types.cs
- SqlReferenceCollection.cs
- DataGridParentRows.cs
- MdImport.cs
- DataGridViewImageCell.cs
- SqlDataSourceView.cs
- BaseCodePageEncoding.cs
- SrgsItemList.cs
- SqlNode.cs
- CompoundFileReference.cs
- StringAttributeCollection.cs
- QilFunction.cs
- SplitterEvent.cs
- DatatypeImplementation.cs
- EntityDataSourceWrapperCollection.cs
- InitiatorSessionSymmetricMessageSecurityProtocol.cs
- SignedXml.cs
- DetectEofStream.cs
- EntityDataSourceViewSchema.cs
- ScriptingProfileServiceSection.cs
- ControlFilterExpression.cs
- WebDescriptionAttribute.cs
- SmtpSection.cs
- FontDialog.cs
- RemoteWebConfigurationHostServer.cs
- BinaryFormatterWriter.cs
- _AutoWebProxyScriptEngine.cs
- Condition.cs
- FaultDescription.cs
- Dictionary.cs
- UriSectionReader.cs
- safex509handles.cs
- QilInvokeEarlyBound.cs
- hresults.cs
- TypeForwardedToAttribute.cs
- WindowsServiceCredential.cs
- RecordConverter.cs
- ContentElement.cs
- SelectedDatesCollection.cs
- ZoneMembershipCondition.cs
- HebrewCalendar.cs
- ByteFacetDescriptionElement.cs
- GridViewCancelEditEventArgs.cs
- ResourceBinder.cs
- ObjectDataSourceEventArgs.cs
- StateItem.cs
- AttachedPropertyBrowsableForTypeAttribute.cs
- TextStore.cs