Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / ndp / fx / src / DataWebControls / System / Data / WebControls / EntityDataSourceWrapperPropertyDescriptor.cs / 3 / EntityDataSourceWrapperPropertyDescriptor.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Data; using System.Configuration; using System.ComponentModel; using System.Data.Common; using System.Data.Metadata.Edm; using System.Reflection; using System.Data.Objects; using System.Data.Objects.DataClasses; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Collections.ObjectModel; using System.Text; namespace System.Web.UI.WebControls { ////// Wrapper property descriptor that handles access of nested members and /// entity reference keys. /// ////// This class essentially glues together a wrapper collection (roughly speaking /// the 'data' exposed by the control) and the column (which defines the metadata /// and behaviors for the current property). /// internal sealed class EntityDataSourceWrapperPropertyDescriptor : PropertyDescriptor { private readonly EntityDataSourceWrapperCollection _collection; private readonly EntityDataSourceColumn _column; internal EntityDataSourceWrapperPropertyDescriptor(EntityDataSourceWrapperCollection collection, EntityDataSourceColumn column) : base(EntityDataSourceUtil.CheckArgumentNull(column, "column").DisplayName, new Attribute[] { }) { EntityDataSourceUtil.CheckArgumentNull(collection, "collection"); _collection = collection; _column = column; } internal EntityDataSourceColumn Column { get { return _column; } } public override Type ComponentType { get { return _collection.ClrEntityType; } } public override bool IsReadOnly { get { return _collection.IsReadOnly || !_column.CanWrite; } } public override Type PropertyType { get { return _column.ClrType; } } public override bool CanResetValue(object component) { return false; } public override void ResetValue(object component) { throw new InvalidOperationException(Strings.ValueNotResettable(this.ComponentType.Name)); } public override object GetValue(object component) { return _column.GetValue(GetWrapper(component)); } public override void SetValue(object component, object value) { if (IsReadOnly) { throw new InvalidOperationException(Strings.SetValueNotSupported); } _column.SetValue(GetWrapper(component), value); } public override bool ShouldSerializeValue(object component) { return false; } private EntityDataSourceWrapper GetWrapper(object component) { // Validate that the component comes from the collection to which // this descriptor is bound. Elements of the collection are // non-null wrappers instances. EntityDataSourceUtil.CheckArgumentNull(component, "component"); EntityDataSourceWrapper wrapper = component as EntityDataSourceWrapper; if (null == wrapper || this._collection != wrapper.Collection) { throw new ArgumentException(Strings.ComponentNotFromProperCollection, "component"); } return wrapper; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //--------------------------------------------------------------------- using System; using System.Data; using System.Configuration; using System.ComponentModel; using System.Data.Common; using System.Data.Metadata.Edm; using System.Reflection; using System.Data.Objects; using System.Data.Objects.DataClasses; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Collections.ObjectModel; using System.Text; namespace System.Web.UI.WebControls { ////// Wrapper property descriptor that handles access of nested members and /// entity reference keys. /// ////// This class essentially glues together a wrapper collection (roughly speaking /// the 'data' exposed by the control) and the column (which defines the metadata /// and behaviors for the current property). /// internal sealed class EntityDataSourceWrapperPropertyDescriptor : PropertyDescriptor { private readonly EntityDataSourceWrapperCollection _collection; private readonly EntityDataSourceColumn _column; internal EntityDataSourceWrapperPropertyDescriptor(EntityDataSourceWrapperCollection collection, EntityDataSourceColumn column) : base(EntityDataSourceUtil.CheckArgumentNull(column, "column").DisplayName, new Attribute[] { }) { EntityDataSourceUtil.CheckArgumentNull(collection, "collection"); _collection = collection; _column = column; } internal EntityDataSourceColumn Column { get { return _column; } } public override Type ComponentType { get { return _collection.ClrEntityType; } } public override bool IsReadOnly { get { return _collection.IsReadOnly || !_column.CanWrite; } } public override Type PropertyType { get { return _column.ClrType; } } public override bool CanResetValue(object component) { return false; } public override void ResetValue(object component) { throw new InvalidOperationException(Strings.ValueNotResettable(this.ComponentType.Name)); } public override object GetValue(object component) { return _column.GetValue(GetWrapper(component)); } public override void SetValue(object component, object value) { if (IsReadOnly) { throw new InvalidOperationException(Strings.SetValueNotSupported); } _column.SetValue(GetWrapper(component), value); } public override bool ShouldSerializeValue(object component) { return false; } private EntityDataSourceWrapper GetWrapper(object component) { // Validate that the component comes from the collection to which // this descriptor is bound. Elements of the collection are // non-null wrappers instances. EntityDataSourceUtil.CheckArgumentNull(component, "component"); EntityDataSourceWrapper wrapper = component as EntityDataSourceWrapper; if (null == wrapper || this._collection != wrapper.Collection) { throw new ArgumentException(Strings.ComponentNotFromProperCollection, "component"); } return wrapper; } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu
This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- IPeerNeighbor.cs
- UndirectedGraph.cs
- ThicknessAnimationUsingKeyFrames.cs
- ObjectDataSourceMethodEventArgs.cs
- CopyAttributesAction.cs
- EventTrigger.cs
- ScopelessEnumAttribute.cs
- PageAsyncTask.cs
- HandlerFactoryCache.cs
- TraceHandlerErrorFormatter.cs
- HandleRef.cs
- InfoCardSymmetricAlgorithm.cs
- OperationResponse.cs
- SortQuery.cs
- SettingsAttributeDictionary.cs
- MetadataCacheItem.cs
- SplineQuaternionKeyFrame.cs
- ChtmlTextWriter.cs
- EntityDataSourceColumn.cs
- RegistryDataKey.cs
- followingsibling.cs
- ProfilePropertyNameValidator.cs
- AssemblySettingAttributes.cs
- ToolBarPanel.cs
- CultureMapper.cs
- HybridDictionary.cs
- UnsafeNativeMethods.cs
- Binding.cs
- BindingsCollection.cs
- DateRangeEvent.cs
- TdsParserSafeHandles.cs
- CodeDefaultValueExpression.cs
- TextStore.cs
- InternalBase.cs
- ObjectStateEntryDbDataRecord.cs
- Evidence.cs
- TransactionProtocolConverter.cs
- ToolStripSplitButton.cs
- ObjectResult.cs
- ToolStripSplitStackLayout.cs
- SafeNativeMethods.cs
- DelegatedStream.cs
- ToolStripDropDownMenu.cs
- UIElement3D.cs
- RtfToken.cs
- PointCollection.cs
- DataGridColumnStyleMappingNameEditor.cs
- Deserializer.cs
- DataSetFieldSchema.cs
- ObjectStateFormatter.cs
- SecUtil.cs
- GAC.cs
- DataKey.cs
- PolicyStatement.cs
- IDQuery.cs
- UnsafeNativeMethods.cs
- ComplexBindingPropertiesAttribute.cs
- ConfigurationConverterBase.cs
- GridViewItemAutomationPeer.cs
- PersonalizableAttribute.cs
- JournalEntryListConverter.cs
- CountAggregationOperator.cs
- ParameterElement.cs
- JavascriptCallbackMessageInspector.cs
- FontClient.cs
- StreamGeometry.cs
- AppDomainAttributes.cs
- RegistrationServices.cs
- XmlReflectionMember.cs
- BlurEffect.cs
- ForAllOperator.cs
- DataServiceRequestArgs.cs
- WebServiceTypeData.cs
- QuaternionRotation3D.cs
- Imaging.cs
- ProfileServiceManager.cs
- OperationResponse.cs
- TypeResolvingOptions.cs
- EmptyEnumerable.cs
- StringFunctions.cs
- PreProcessInputEventArgs.cs
- IdentitySection.cs
- RemoteEndpointMessageProperty.cs
- XmlReader.cs
- MultiBindingExpression.cs
- ListViewSelectEventArgs.cs
- LiteralControl.cs
- FileLogRecord.cs
- HttpListenerElement.cs
- CellQuery.cs
- PointLight.cs
- XmlEnumAttribute.cs
- SchemaImporterExtensionsSection.cs
- LocatorGroup.cs
- KeyManager.cs
- TheQuery.cs
- ExpressionBuilder.cs
- LicenseContext.cs
- RequestResizeEvent.cs
- EmptyEnumerator.cs