Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / MemberMemberBinding.cs / 1305376 / MemberMemberBinding.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.Dynamic.Utils; using System.Reflection; #if SILVERLIGHT using System.Core; #endif namespace System.Linq.Expressions { ////// Represents initializing members of a member of a newly created object. /// ////// Use the public sealed class MemberMemberBinding : MemberBinding { ReadOnlyCollectionfactory methods to create a . /// The value of the property of a object is . /// _bindings; internal MemberMemberBinding(MemberInfo member, ReadOnlyCollection bindings) #pragma warning disable 618 : base(MemberBindingType.MemberBinding, member) { #pragma warning restore 618 _bindings = bindings; } /// /// Gets the bindings that describe how to initialize the members of a member. /// public ReadOnlyCollectionBindings { get { return _bindings; } } /// /// 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 MemberMemberBinding Update(IEnumerablebindings) { if (bindings == Bindings) { return this; } return Expression.MemberBind(Member, bindings); } } public partial class Expression { /// /// Creates a /// Thethat represents the recursive initialization of members of a field or property. /// to set the property equal to. /// An array of objects to use to populate the collection. /// A public static MemberMemberBinding MemberBind(MemberInfo member, params MemberBinding[] bindings) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(bindings, "bindings"); return MemberBind(member, (IEnumerablethat has the property equal to and the and properties set to the specified values. )bindings); } /// /// Creates a /// Thethat represents the recursive initialization of members of a field or property. /// to set the property equal to. /// An that contains objects to use to populate the collection. /// A public static MemberMemberBinding MemberBind(MemberInfo member, IEnumerablethat has the property equal to and the and properties set to the specified values. bindings) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(bindings, "bindings"); ReadOnlyCollection roBindings = bindings.ToReadOnly(); Type memberType; ValidateGettableFieldOrPropertyMember(member, out memberType); ValidateMemberInitArgs(memberType, roBindings); return new MemberMemberBinding(member, roBindings); } /// /// Creates a /// Thethat represents the recursive initialization of members of a member that is accessed by using a property accessor method. /// that represents a property accessor method. /// An that contains objects to use to populate the collection. /// /// A public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, params MemberBinding[] bindings) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); return MemberBind(GetProperty(propertyAccessor), bindings); } ///that has the property equal to , /// the Member property set to the that represents the property accessed in , /// and properties set to the specified values. /// /// Creates a /// Thethat represents the recursive initialization of members of a member that is accessed by using a property accessor method. /// that represents a property accessor method. /// An that contains objects to use to populate the collection. /// /// A public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, IEnumerablethat has the property equal to , /// the Member property set to the that represents the property accessed in , /// and properties set to the specified values. /// bindings) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); return MemberBind(GetProperty(propertyAccessor), bindings); } private static void ValidateGettableFieldOrPropertyMember(MemberInfo member, out Type memberType) { FieldInfo fi = member as FieldInfo; if (fi == null) { PropertyInfo pi = member as PropertyInfo; if (pi == null) { throw Error.ArgumentMustBeFieldInfoOrPropertInfo(); } if (!pi.CanRead) { throw Error.PropertyDoesNotHaveGetter(pi); } memberType = pi.PropertyType; } else { memberType = fi.FieldType; } } private static void ValidateMemberInitArgs(Type type, ReadOnlyCollection bindings) { for (int i = 0, n = bindings.Count; i < n; i++) { MemberBinding b = bindings[i]; ContractUtils.RequiresNotNull(b, "bindings"); if (!b.Member.DeclaringType.IsAssignableFrom(type)) { throw Error.NotAMemberOfType(b.Member.Name, type); } } } } } // 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.Dynamic.Utils; using System.Reflection; #if SILVERLIGHT using System.Core; #endif namespace System.Linq.Expressions { /// /// Represents initializing members of a member of a newly created object. /// ////// Use the public sealed class MemberMemberBinding : MemberBinding { ReadOnlyCollectionfactory methods to create a . /// The value of the property of a object is . /// _bindings; internal MemberMemberBinding(MemberInfo member, ReadOnlyCollection bindings) #pragma warning disable 618 : base(MemberBindingType.MemberBinding, member) { #pragma warning restore 618 _bindings = bindings; } /// /// Gets the bindings that describe how to initialize the members of a member. /// public ReadOnlyCollectionBindings { get { return _bindings; } } /// /// 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 MemberMemberBinding Update(IEnumerablebindings) { if (bindings == Bindings) { return this; } return Expression.MemberBind(Member, bindings); } } public partial class Expression { /// /// Creates a /// Thethat represents the recursive initialization of members of a field or property. /// to set the property equal to. /// An array of objects to use to populate the collection. /// A public static MemberMemberBinding MemberBind(MemberInfo member, params MemberBinding[] bindings) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(bindings, "bindings"); return MemberBind(member, (IEnumerablethat has the property equal to and the and properties set to the specified values. )bindings); } /// /// Creates a /// Thethat represents the recursive initialization of members of a field or property. /// to set the property equal to. /// An that contains objects to use to populate the collection. /// A public static MemberMemberBinding MemberBind(MemberInfo member, IEnumerablethat has the property equal to and the and properties set to the specified values. bindings) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(bindings, "bindings"); ReadOnlyCollection roBindings = bindings.ToReadOnly(); Type memberType; ValidateGettableFieldOrPropertyMember(member, out memberType); ValidateMemberInitArgs(memberType, roBindings); return new MemberMemberBinding(member, roBindings); } /// /// Creates a /// Thethat represents the recursive initialization of members of a member that is accessed by using a property accessor method. /// that represents a property accessor method. /// An that contains objects to use to populate the collection. /// /// A public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, params MemberBinding[] bindings) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); return MemberBind(GetProperty(propertyAccessor), bindings); } ///that has the property equal to , /// the Member property set to the that represents the property accessed in , /// and properties set to the specified values. /// /// Creates a /// Thethat represents the recursive initialization of members of a member that is accessed by using a property accessor method. /// that represents a property accessor method. /// An that contains objects to use to populate the collection. /// /// A public static MemberMemberBinding MemberBind(MethodInfo propertyAccessor, IEnumerablethat has the property equal to , /// the Member property set to the that represents the property accessed in , /// and properties set to the specified values. /// bindings) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); return MemberBind(GetProperty(propertyAccessor), bindings); } private static void ValidateGettableFieldOrPropertyMember(MemberInfo member, out Type memberType) { FieldInfo fi = member as FieldInfo; if (fi == null) { PropertyInfo pi = member as PropertyInfo; if (pi == null) { throw Error.ArgumentMustBeFieldInfoOrPropertInfo(); } if (!pi.CanRead) { throw Error.PropertyDoesNotHaveGetter(pi); } memberType = pi.PropertyType; } else { memberType = fi.FieldType; } } private static void ValidateMemberInitArgs(Type type, ReadOnlyCollection bindings) { for (int i = 0, n = bindings.Count; i < n; i++) { MemberBinding b = bindings[i]; ContractUtils.RequiresNotNull(b, "bindings"); if (!b.Member.DeclaringType.IsAssignableFrom(type)) { throw Error.NotAMemberOfType(b.Member.Name, type); } } } } } // 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
- XmlSchema.cs
- FormViewInsertedEventArgs.cs
- PrintPreviewDialog.cs
- CachingHintValidation.cs
- FontNamesConverter.cs
- DataGridRow.cs
- IgnoreFlushAndCloseStream.cs
- SystemIPAddressInformation.cs
- CrossContextChannel.cs
- PrivilegeNotHeldException.cs
- ObjectFullSpanRewriter.cs
- DataDocumentXPathNavigator.cs
- ToolStripGripRenderEventArgs.cs
- XamlPathDataSerializer.cs
- Ppl.cs
- RtfControls.cs
- ScriptingSectionGroup.cs
- CollectionChangeEventArgs.cs
- NumericPagerField.cs
- EnumMemberAttribute.cs
- DocumentGridPage.cs
- AppSettingsSection.cs
- XPathMessageFilterElementCollection.cs
- UnmanagedMemoryStreamWrapper.cs
- URL.cs
- DodSequenceMerge.cs
- FontInfo.cs
- EntityDataSourceQueryBuilder.cs
- PageThemeBuildProvider.cs
- XmlSchemaElement.cs
- SynchronousChannelMergeEnumerator.cs
- PerspectiveCamera.cs
- DelayDesigner.cs
- selecteditemcollection.cs
- SqlDataSourceTableQuery.cs
- InputBuffer.cs
- FacetValues.cs
- TargetControlTypeCache.cs
- MappingException.cs
- QuaternionValueSerializer.cs
- XmlUrlEditor.cs
- ResolveNameEventArgs.cs
- SqlBinder.cs
- DataGridState.cs
- DataGridViewAccessibleObject.cs
- NumericExpr.cs
- InstancePersistenceEvent.cs
- XmlQueryType.cs
- ListViewContainer.cs
- DbConnectionStringBuilder.cs
- XmlEntity.cs
- XDeferredAxisSource.cs
- RemotingSurrogateSelector.cs
- LinqDataSourceSelectEventArgs.cs
- VerbConverter.cs
- SettingsPropertyIsReadOnlyException.cs
- FontDialog.cs
- MultiBindingExpression.cs
- Matrix.cs
- Timeline.cs
- GenerateScriptTypeAttribute.cs
- AssemblySettingAttributes.cs
- GlobalEventManager.cs
- GrammarBuilderBase.cs
- SafeRightsManagementHandle.cs
- MdiWindowListStrip.cs
- ClassDataContract.cs
- BitmapEffectGroup.cs
- PowerModeChangedEventArgs.cs
- XmlArrayItemAttribute.cs
- OverlappedAsyncResult.cs
- SerializationException.cs
- QuerySettings.cs
- RelationHandler.cs
- XmlName.cs
- EntityContainerEmitter.cs
- BatchParser.cs
- _BasicClient.cs
- XmlQualifiedNameTest.cs
- DataAdapter.cs
- WeakReference.cs
- ContentPresenter.cs
- FileInfo.cs
- CharacterHit.cs
- MaskInputRejectedEventArgs.cs
- InvalidateEvent.cs
- ListViewGroup.cs
- FontUnit.cs
- HelpKeywordAttribute.cs
- GlyphRun.cs
- FormViewPageEventArgs.cs
- XPathException.cs
- XmlSchemaChoice.cs
- ColumnCollection.cs
- CalendarDay.cs
- PointCollectionValueSerializer.cs
- ArrayTypeMismatchException.cs
- FieldAccessException.cs
- MonthCalendar.cs
- ClassicBorderDecorator.cs