Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Actions / DynamicMetaObject.cs / 1305376 / DynamicMetaObject.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.Dynamic.Utils; using System.Linq.Expressions; using System.Reflection; #if SILVERLIGHT using System.Core; #else using System.Runtime.Remoting; #endif namespace System.Dynamic { ////// Represents the dynamic binding and a binding logic of an object participating in the dynamic binding. /// public class DynamicMetaObject { private readonly Expression _expression; private readonly BindingRestrictions _restrictions; private readonly object _value; private readonly bool _hasValue; ////// Represents an empty array of type [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2105:ArrayFieldsShouldNotBeReadOnly")] public static readonly DynamicMetaObject[] EmptyMetaObjects = new DynamicMetaObject[0]; ///. This field is read only. /// /// Initializes a new instance of the /// The expression representing thisclass. /// during the dynamic binding process. /// The set of binding restrictions under which the binding is valid. public DynamicMetaObject(Expression expression, BindingRestrictions restrictions) { ContractUtils.RequiresNotNull(expression, "expression"); ContractUtils.RequiresNotNull(restrictions, "restrictions"); _expression = expression; _restrictions = restrictions; } /// /// Initializes a new instance of the /// The expression representing thisclass. /// during the dynamic binding process. /// The set of binding restrictions under which the binding is valid. /// The runtime value represented by the . public DynamicMetaObject(Expression expression, BindingRestrictions restrictions, object value) : this(expression, restrictions) { _value = value; _hasValue = true; } /// /// The expression representing the public Expression Expression { get { return _expression; } } ///during the dynamic binding process. /// /// The set of binding restrictions under which the binding is valid. /// public BindingRestrictions Restrictions { get { return _restrictions; } } ////// The runtime value represented by this public object Value { get { return _value; } } ///. /// /// Gets a value indicating whether the public bool HasValue { get { return _hasValue; } } ///has the runtime value. /// /// Gets the public Type RuntimeType { get { if (_hasValue) { Type ct = Expression.Type; // valuetype at compile tyme, type cannot change. if (ct.IsValueType) { return ct; } if (_value != null) { return _value.GetType(); } else { return null; } } else { return null; } } } ///of the runtime value or null if the has no value associated with it. /// /// Gets the limit type of the ///. /// Represents the most specific type known about the object represented by the public Type LimitType { get { return RuntimeType ?? Expression.Type; } } ///. if runtime value is available, a type of the otherwise. /// Performs the binding of the dynamic conversion operation. /// /// An instance of thethat represents the details of the dynamic operation. /// The new public virtual DynamicMetaObject BindConvert(ConvertBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackConvert(this); } ///representing the result of the binding. /// Performs the binding of the dynamic get member operation. /// /// An instance of thethat represents the details of the dynamic operation. /// The new public virtual DynamicMetaObject BindGetMember(GetMemberBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackGetMember(this); } ///representing the result of the binding. /// Performs the binding of the dynamic set member operation. /// /// An instance of thethat represents the details of the dynamic operation. /// The representing the value for the set member operation. /// The new public virtual DynamicMetaObject BindSetMember(SetMemberBinder binder, DynamicMetaObject value) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackSetMember(this, value); } ///representing the result of the binding. /// Performs the binding of the dynamic delete member operation. /// /// An instance of thethat represents the details of the dynamic operation. /// The new public virtual DynamicMetaObject BindDeleteMember(DeleteMemberBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackDeleteMember(this); } ///representing the result of the binding. /// Performs the binding of the dynamic get index operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - indexes for the get index operation. /// The new public virtual DynamicMetaObject BindGetIndex(GetIndexBinder binder, DynamicMetaObject[] indexes) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackGetIndex(this, indexes); } ///representing the result of the binding. /// Performs the binding of the dynamic set index operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - indexes for the set index operation. /// The representing the value for the set index operation. /// The new public virtual DynamicMetaObject BindSetIndex(SetIndexBinder binder, DynamicMetaObject[] indexes, DynamicMetaObject value) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackSetIndex(this, indexes, value); } ///representing the result of the binding. /// Performs the binding of the dynamic delete index operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - indexes for the delete index operation. /// The new public virtual DynamicMetaObject BindDeleteIndex(DeleteIndexBinder binder, DynamicMetaObject[] indexes) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackDeleteIndex(this, indexes); } ///representing the result of the binding. /// Performs the binding of the dynamic invoke member operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - arguments to the invoke member operation. /// The new public virtual DynamicMetaObject BindInvokeMember(InvokeMemberBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackInvokeMember(this, args); } ///representing the result of the binding. /// Performs the binding of the dynamic invoke operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - arguments to the invoke operation. /// The new public virtual DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackInvoke(this, args); } ///representing the result of the binding. /// Performs the binding of the dynamic create instance operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An array of instances - arguments to the create instance operation. /// The new public virtual DynamicMetaObject BindCreateInstance(CreateInstanceBinder binder, DynamicMetaObject[] args) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackCreateInstance(this, args); } ///representing the result of the binding. /// Performs the binding of the dynamic unary operation. /// /// An instance of thethat represents the details of the dynamic operation. /// The new public virtual DynamicMetaObject BindUnaryOperation(UnaryOperationBinder binder) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackUnaryOperation(this); } ///representing the result of the binding. /// Performs the binding of the dynamic binary operation. /// /// An instance of thethat represents the details of the dynamic operation. /// An instance of the representing the right hand side of the binary operation. /// The new public virtual DynamicMetaObject BindBinaryOperation(BinaryOperationBinder binder, DynamicMetaObject arg) { ContractUtils.RequiresNotNull(binder, "binder"); return binder.FallbackBinaryOperation(this, arg); } ///representing the result of the binding. /// Returns the enumeration of all dynamic member names. /// ///The list of dynamic member names. [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1024:UsePropertiesWhereAppropriate")] public virtual IEnumerableGetDynamicMemberNames() { return new string[0]; } /// /// Returns the list of expressions represented by the /// An array ofinstances. /// instances to extract expressions from. /// The array of expressions. internal static Expression[] GetExpressions(DynamicMetaObject[] objects) { ContractUtils.RequiresNotNull(objects, "objects"); Expression[] res = new Expression[objects.Length]; for (int i = 0; i < objects.Length; i++) { DynamicMetaObject mo = objects[i]; ContractUtils.RequiresNotNull(mo, "objects"); Expression expr = mo.Expression; ContractUtils.RequiresNotNull(expr, "objects"); res[i] = expr; } return res; } ////// Creates a meta-object for the specified object. /// /// The object to get a meta-object for. /// The expression representing thisduring the dynamic binding process. /// /// If the given object implements public static DynamicMetaObject Create(object value, Expression expression) { ContractUtils.RequiresNotNull(expression, "expression"); IDynamicMetaObjectProvider ido = value as IDynamicMetaObjectProvider; #if !SILVERLIGHT if (ido != null && !RemotingServices.IsObjectOutOfAppDomain(value)) { #else if (ido != null) { #endif var idoMetaObject = ido.GetMetaObject(expression); if (idoMetaObject == null || !idoMetaObject.HasValue || idoMetaObject.Value == null || (object)idoMetaObject.Expression != (object)expression) { throw Error.InvalidMetaObjectCreated(ido.GetType()); } return idoMetaObject; } else { return new DynamicMetaObject(expression, BindingRestrictions.Empty, value); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved.and is not a remote object from outside the current AppDomain, /// returns the object's specific meta-object returned by . Otherwise a plain new meta-object /// with no restrictions is created and returned. ///
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- DataGridRelationshipRow.cs
- InkPresenterAutomationPeer.cs
- EntityDesignerBuildProvider.cs
- SendMailErrorEventArgs.cs
- ConfigXmlSignificantWhitespace.cs
- MouseCaptureWithinProperty.cs
- AlgoModule.cs
- StylusSystemGestureEventArgs.cs
- Empty.cs
- GetMemberBinder.cs
- DesignerMetadata.cs
- LinqDataView.cs
- PropertyState.cs
- ResourcePermissionBaseEntry.cs
- HttpException.cs
- BaseDataList.cs
- MimeTypeMapper.cs
- ServiceReference.cs
- AdRotatorDesigner.cs
- RichTextBox.cs
- ConnectivityStatus.cs
- HttpCapabilitiesSectionHandler.cs
- CreatingCookieEventArgs.cs
- LogManagementAsyncResult.cs
- OdbcDataAdapter.cs
- InvalidEnumArgumentException.cs
- ComponentRenameEvent.cs
- ToolStripDropTargetManager.cs
- ApplicationServiceManager.cs
- PropertyStore.cs
- StringAnimationUsingKeyFrames.cs
- CacheMemory.cs
- PowerStatus.cs
- TextDecoration.cs
- PrimitiveXmlSerializers.cs
- SystemUnicastIPAddressInformation.cs
- BindingObserver.cs
- OdbcEnvironmentHandle.cs
- RangeContentEnumerator.cs
- UniqueEventHelper.cs
- MeasurementDCInfo.cs
- ManagementOptions.cs
- TemplatePropertyEntry.cs
- EventLogPermission.cs
- CircleHotSpot.cs
- BindingManagerDataErrorEventArgs.cs
- ConnectionPoint.cs
- WebPartEditorOkVerb.cs
- SessionEndedEventArgs.cs
- XmlTypeAttribute.cs
- TransportSecurityProtocolFactory.cs
- BindingWorker.cs
- IPipelineRuntime.cs
- SettingsSection.cs
- SchemaAttDef.cs
- GlyphTypeface.cs
- PathFigureCollectionConverter.cs
- ColumnReorderedEventArgs.cs
- DataGridViewColumn.cs
- ChannelTerminatedException.cs
- SqlNodeAnnotations.cs
- EncoderFallback.cs
- X509SecurityTokenParameters.cs
- JavaScriptSerializer.cs
- BehaviorService.cs
- JsonStringDataContract.cs
- TextViewSelectionProcessor.cs
- wpf-etw.cs
- CompositeCollection.cs
- hebrewshape.cs
- ArgIterator.cs
- _AutoWebProxyScriptWrapper.cs
- Connector.xaml.cs
- HashCodeCombiner.cs
- LambdaCompiler.Unary.cs
- VirtualPathData.cs
- BypassElement.cs
- oledbmetadatacollectionnames.cs
- SqlRecordBuffer.cs
- ProcessHostServerConfig.cs
- InternalConfigEventArgs.cs
- AppSettingsExpressionEditor.cs
- CheckBoxFlatAdapter.cs
- Crc32.cs
- StrongTypingException.cs
- XmlAutoDetectWriter.cs
- NativeMethods.cs
- ListenerChannelContext.cs
- RuntimeResourceSet.cs
- XamlContextStack.cs
- NavigationHelper.cs
- RelationshipEnd.cs
- RawStylusInput.cs
- GeometryCollection.cs
- EasingKeyFrames.cs
- XPathChildIterator.cs
- PropertyEmitter.cs
- FlowDocumentReaderAutomationPeer.cs
- VarRefManager.cs
- WebProxyScriptElement.cs