Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWebControls / System / Data / WebControls / EntityDataSourceWrapperPropertyDescriptor.cs / 1305376 / 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
- _NegoState.cs
- WebMessageEncodingElement.cs
- DependencyObjectProvider.cs
- SoapFaultCodes.cs
- RegexCharClass.cs
- IInstanceContextProvider.cs
- ResourceManagerWrapper.cs
- ScrollBar.cs
- IndexedEnumerable.cs
- ErrorFormatter.cs
- ScrollViewerAutomationPeer.cs
- RowUpdatedEventArgs.cs
- HttpPostedFile.cs
- FacetValueContainer.cs
- DurableOperationContext.cs
- HttpResponseMessageProperty.cs
- WindowsSecurityTokenAuthenticator.cs
- SelectionProviderWrapper.cs
- JoinGraph.cs
- ToolboxComponentsCreatingEventArgs.cs
- XsltException.cs
- Quad.cs
- XmlnsDictionary.cs
- GroupByQueryOperator.cs
- LazyTextWriterCreator.cs
- ApplicationFileCodeDomTreeGenerator.cs
- TextBoxAutoCompleteSourceConverter.cs
- SQLBytesStorage.cs
- UnauthorizedWebPart.cs
- ToolStripButton.cs
- FormsAuthenticationTicket.cs
- HttpValueCollection.cs
- SiteMembershipCondition.cs
- SQLRoleProvider.cs
- ReadOnlyDataSourceView.cs
- TabControlEvent.cs
- ProgressBarHighlightConverter.cs
- AcceleratedTokenProviderState.cs
- DataGridViewAutoSizeColumnModeEventArgs.cs
- PlaceHolder.cs
- LassoHelper.cs
- FontDialog.cs
- GridViewUpdateEventArgs.cs
- ImageMap.cs
- ExtendedProtectionPolicyElement.cs
- MemoryPressure.cs
- StringValidatorAttribute.cs
- SslStream.cs
- WorkflowViewService.cs
- DBSqlParser.cs
- ConstraintStruct.cs
- SecurityStateEncoder.cs
- DataRowCollection.cs
- ListViewGroupItemCollection.cs
- SafeHandle.cs
- SR.Designer.cs
- SchemaContext.cs
- ThemeInfoAttribute.cs
- BaseAddressElement.cs
- Query.cs
- RequestCachePolicy.cs
- CngAlgorithmGroup.cs
- DesignerUtils.cs
- TemplateBamlRecordReader.cs
- ReachDocumentSequenceSerializer.cs
- UrlMapping.cs
- ColorBlend.cs
- Table.cs
- ByteFacetDescriptionElement.cs
- VectorValueSerializer.cs
- ImpersonateTokenRef.cs
- XsdCachingReader.cs
- CutCopyPasteHelper.cs
- Int32Animation.cs
- Errors.cs
- CounterSampleCalculator.cs
- TargetFrameworkAttribute.cs
- BlobPersonalizationState.cs
- TableCellsCollectionEditor.cs
- ProfileService.cs
- TypeDescriptor.cs
- CreatingCookieEventArgs.cs
- Policy.cs
- StretchValidation.cs
- FixedNode.cs
- ToolStripMenuItem.cs
- StandardTransformFactory.cs
- util.cs
- XmlBufferedByteStreamReader.cs
- OptimizerPatterns.cs
- SearchForVirtualItemEventArgs.cs
- DetailsViewUpdateEventArgs.cs
- DictionaryGlobals.cs
- httpapplicationstate.cs
- WebSysDefaultValueAttribute.cs
- CodeTypeParameter.cs
- RegisteredDisposeScript.cs
- PersonalizableAttribute.cs
- CapacityStreamGeometryContext.cs
- SecurityHelper.cs