Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / Core / Microsoft / Scripting / Ast / MemberListBinding.cs / 1305376 / MemberListBinding.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; 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 the elements of a collection member of a newly created object. /// public sealed class MemberListBinding : MemberBinding { ReadOnlyCollection_initializers; internal MemberListBinding(MemberInfo member, ReadOnlyCollection initializers) #pragma warning disable 618 : base(MemberBindingType.ListBinding, member) { #pragma warning restore 618 _initializers = initializers; } /// /// Gets the element initializers for initializing a collection member of a newly created object. /// public ReadOnlyCollectionInitializers { get { return _initializers; } } /// /// 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 MemberListBinding Update(IEnumerableinitializers) { if (initializers == Initializers) { return this; } return Expression.ListBind(Member, initializers); } } public partial class Expression { /// Creates a ///where the member is a field or property. A ///Athat has the property equal to and the and properties set to the specified values. that represents a field or property to set the property equal to. ///An array of objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(member, (IEnumerabledoes not represent a field or property.-or-The or of the field or property that represents does not implement . )initializers); } /// Creates a ///where the member is a field or property. A ///Athat has the property equal to and the and properties set to the specified values. that represents a field or property to set the property equal to. ///An that contains objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MemberInfo member, IEnumerabledoes not represent a field or property.-or-The or of the field or property that represents does not implement . initializers) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(initializers, "initializers"); Type memberType; ValidateGettableFieldOrPropertyMember(member, out memberType); var initList = initializers.ToReadOnly(); ValidateListInitArgs(memberType, initList); return new MemberListBinding(member, initList); } /// Creates a ///object based on a specified property accessor method. A ///Athat has the property equal to , the property set to the that represents the property accessed in , and populated with the elements of . that represents a property accessor method. ///An array of objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MethodInfo propertyAccessor, params ElementInit[] initializers) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(propertyAccessor, (IEnumerabledoes not represent a property accessor method.-or-The of the property that the method represented by accesses does not implement . )initializers); } /// Creates a ///based on a specified property accessor method. A ///Athat has the property equal to , the property set to the that represents the property accessed in , and populated with the elements of . that represents a property accessor method. ///An that contains objects to use to populate the collection. /// /// ///is null. -or-One or more elements of are null. /// public static MemberListBinding ListBind(MethodInfo propertyAccessor, IEnumerabledoes not represent a property accessor method.-or-The of the property that the method represented by accesses does not implement . initializers) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(GetProperty(propertyAccessor), initializers); } private static void ValidateListInitArgs(Type listType, ReadOnlyCollection initializers) { if (!typeof(IEnumerable).IsAssignableFrom(listType)) { throw Error.TypeNotIEnumerable(listType); } for (int i = 0, n = initializers.Count; i < n; i++) { ElementInit element = initializers[i]; ContractUtils.RequiresNotNull(element, "initializers"); ValidateCallInstanceType(listType, element.AddMethod); } } } } // 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; 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 the elements of a collection member of a newly created object. /// public sealed class MemberListBinding : MemberBinding { ReadOnlyCollection_initializers; internal MemberListBinding(MemberInfo member, ReadOnlyCollection initializers) #pragma warning disable 618 : base(MemberBindingType.ListBinding, member) { #pragma warning restore 618 _initializers = initializers; } /// /// Gets the element initializers for initializing a collection member of a newly created object. /// public ReadOnlyCollectionInitializers { get { return _initializers; } } /// /// 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 MemberListBinding Update(IEnumerableinitializers) { if (initializers == Initializers) { return this; } return Expression.ListBind(Member, initializers); } } public partial class Expression { /// Creates a ///where the member is a field or property. A ///Athat has the property equal to and the and properties set to the specified values. that represents a field or property to set the property equal to. ///An array of objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MemberInfo member, params ElementInit[] initializers) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(member, (IEnumerabledoes not represent a field or property.-or-The or of the field or property that represents does not implement . )initializers); } /// Creates a ///where the member is a field or property. A ///Athat has the property equal to and the and properties set to the specified values. that represents a field or property to set the property equal to. ///An that contains objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MemberInfo member, IEnumerabledoes not represent a field or property.-or-The or of the field or property that represents does not implement . initializers) { ContractUtils.RequiresNotNull(member, "member"); ContractUtils.RequiresNotNull(initializers, "initializers"); Type memberType; ValidateGettableFieldOrPropertyMember(member, out memberType); var initList = initializers.ToReadOnly(); ValidateListInitArgs(memberType, initList); return new MemberListBinding(member, initList); } /// Creates a ///object based on a specified property accessor method. A ///Athat has the property equal to , the property set to the that represents the property accessed in , and populated with the elements of . that represents a property accessor method. ///An array of objects to use to populate the collection. /// /// ///is null. -or-One or more elements of is null. /// public static MemberListBinding ListBind(MethodInfo propertyAccessor, params ElementInit[] initializers) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(propertyAccessor, (IEnumerabledoes not represent a property accessor method.-or-The of the property that the method represented by accesses does not implement . )initializers); } /// Creates a ///based on a specified property accessor method. A ///Athat has the property equal to , the property set to the that represents the property accessed in , and populated with the elements of . that represents a property accessor method. ///An that contains objects to use to populate the collection. /// /// ///is null. -or-One or more elements of are null. /// public static MemberListBinding ListBind(MethodInfo propertyAccessor, IEnumerabledoes not represent a property accessor method.-or-The of the property that the method represented by accesses does not implement . initializers) { ContractUtils.RequiresNotNull(propertyAccessor, "propertyAccessor"); ContractUtils.RequiresNotNull(initializers, "initializers"); return ListBind(GetProperty(propertyAccessor), initializers); } private static void ValidateListInitArgs(Type listType, ReadOnlyCollection initializers) { if (!typeof(IEnumerable).IsAssignableFrom(listType)) { throw Error.TypeNotIEnumerable(listType); } for (int i = 0, n = initializers.Count; i < n; i++) { ElementInit element = initializers[i]; ContractUtils.RequiresNotNull(element, "initializers"); ValidateCallInstanceType(listType, element.AddMethod); } } } } // 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
- EnumUnknown.cs
- ContravarianceAdapter.cs
- AutomationElementCollection.cs
- MappingMetadataHelper.cs
- XmlSiteMapProvider.cs
- GrammarBuilderDictation.cs
- XamlTypeWithExplicitNamespace.cs
- WebBrowsableAttribute.cs
- WorkflowServiceHostFactory.cs
- ChannelSinkStacks.cs
- CodeDOMUtility.cs
- BaseCollection.cs
- ExpressionContext.cs
- EncoderParameters.cs
- DocumentXmlWriter.cs
- PartialList.cs
- TextCharacters.cs
- Duration.cs
- SiteMapDataSource.cs
- StoreContentChangedEventArgs.cs
- XmlSchemaSet.cs
- WorkflowInstanceSuspendedRecord.cs
- SettingsSection.cs
- TemplateColumn.cs
- GridViewCommandEventArgs.cs
- CommandBindingCollection.cs
- DataGridViewCellParsingEventArgs.cs
- HtmlInputReset.cs
- Win32.cs
- FormViewPageEventArgs.cs
- XmlSchemaSimpleType.cs
- SqlBuilder.cs
- ModelFunction.cs
- LambdaCompiler.Address.cs
- ExpressionEditorAttribute.cs
- KeyEvent.cs
- recordstate.cs
- PolyBezierSegmentFigureLogic.cs
- MetadataImporter.cs
- ContainerFilterService.cs
- KeyToListMap.cs
- DBConcurrencyException.cs
- HttpModuleActionCollection.cs
- storepermissionattribute.cs
- CaseExpr.cs
- Win32.cs
- DirectoryObjectSecurity.cs
- ScriptControlDescriptor.cs
- Literal.cs
- SoapExtension.cs
- Model3D.cs
- HideDisabledControlAdapter.cs
- GlyphRunDrawing.cs
- ToolStripItemEventArgs.cs
- TemplateField.cs
- FileUtil.cs
- ChtmlPhoneCallAdapter.cs
- TraceFilter.cs
- RectIndependentAnimationStorage.cs
- HttpServerVarsCollection.cs
- ScriptingWebServicesSectionGroup.cs
- ServiceDurableInstanceContextProvider.cs
- XamlLoadErrorInfo.cs
- RenamedEventArgs.cs
- OracleRowUpdatingEventArgs.cs
- ConvertEvent.cs
- PropertyGrid.cs
- HtmlContainerControl.cs
- XmlSchemaSearchPattern.cs
- StructuredProperty.cs
- EntityDataReader.cs
- ReferentialConstraintRoleElement.cs
- RewritingValidator.cs
- PersonalizableAttribute.cs
- RandomDelayQueuedSendsAsyncResult.cs
- DefaultPerformanceCounters.cs
- UntrustedRecipientException.cs
- XXXInfos.cs
- ApplicationCommands.cs
- MappingItemCollection.cs
- BaseConfigurationRecord.cs
- XmlDocumentSchema.cs
- CfgArc.cs
- HyperLinkStyle.cs
- DesignerExtenders.cs
- IisTraceWebEventProvider.cs
- CompressedStack.cs
- DataErrorValidationRule.cs
- DecoratedNameAttribute.cs
- DataGridColumnReorderingEventArgs.cs
- WindowsListViewSubItem.cs
- Atom10FormatterFactory.cs
- PasswordBox.cs
- WasHttpHandlersInstallComponent.cs
- TransformerTypeCollection.cs
- Encoder.cs
- FixedFindEngine.cs
- HashAlgorithm.cs
- DropDownList.cs
- NativeMethods.cs