Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / ModelProviders / SimpleTableProvider.cs / 1305376 / SimpleTableProvider.cs
namespace System.Web.DynamicData.ModelProviders {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
internal sealed class SimpleTableProvider : TableProvider {
private List _columns;
private ICustomTypeDescriptor _descriptor;
public SimpleTableProvider(DataModelProvider modelProvider, Type entityType)
: base(modelProvider) {
if (entityType == null) {
throw new ArgumentNullException("entityType");
}
EntityType = entityType;
Name = entityType.Name;
DataContextPropertyName = String.Empty;
InitializeColumns(TypeDescriptor.GetProperties(entityType));
}
public SimpleTableProvider(DataModelProvider modelProvider, ICustomTypeDescriptor descriptor)
: base(modelProvider) {
if (descriptor == null) {
throw new ArgumentNullException("descriptor");
}
_descriptor = descriptor;
Name = descriptor.GetClassName();
DataContextPropertyName = String.Empty;
InitializeColumns(descriptor.GetProperties());
}
public override ReadOnlyCollection Columns {
get {
return _columns.AsReadOnly();
}
}
public override ICustomTypeDescriptor GetTypeDescriptor() {
return _descriptor ?? base.GetTypeDescriptor();
}
public override IQueryable GetQuery(object context) {
throw new NotSupportedException();
}
private void InitializeColumns(PropertyDescriptorCollection columnDescriptors) {
_columns = columnDescriptors.OfType().Select(p => new SimpleColumnProvider(this, p)).OfType().ToList();
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
namespace System.Web.DynamicData.ModelProviders {
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.ObjectModel;
using System.ComponentModel;
internal sealed class SimpleTableProvider : TableProvider {
private List _columns;
private ICustomTypeDescriptor _descriptor;
public SimpleTableProvider(DataModelProvider modelProvider, Type entityType)
: base(modelProvider) {
if (entityType == null) {
throw new ArgumentNullException("entityType");
}
EntityType = entityType;
Name = entityType.Name;
DataContextPropertyName = String.Empty;
InitializeColumns(TypeDescriptor.GetProperties(entityType));
}
public SimpleTableProvider(DataModelProvider modelProvider, ICustomTypeDescriptor descriptor)
: base(modelProvider) {
if (descriptor == null) {
throw new ArgumentNullException("descriptor");
}
_descriptor = descriptor;
Name = descriptor.GetClassName();
DataContextPropertyName = String.Empty;
InitializeColumns(descriptor.GetProperties());
}
public override ReadOnlyCollection Columns {
get {
return _columns.AsReadOnly();
}
}
public override ICustomTypeDescriptor GetTypeDescriptor() {
return _descriptor ?? base.GetTypeDescriptor();
}
public override IQueryable GetQuery(object context) {
throw new NotSupportedException();
}
private void InitializeColumns(PropertyDescriptorCollection columnDescriptors) {
_columns = columnDescriptors.OfType().Select(p => new SimpleColumnProvider(this, p)).OfType().ToList();
}
}
}
// 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
- OutputScopeManager.cs
- ModelItem.cs
- SessionPageStatePersister.cs
- XmlDomTextWriter.cs
- DictionarySectionHandler.cs
- AnnotationStore.cs
- OdbcConnectionOpen.cs
- DesignerTransactionCloseEvent.cs
- WindowsPrincipal.cs
- dtdvalidator.cs
- SqlDependency.cs
- ContentIterators.cs
- BooleanKeyFrameCollection.cs
- IDReferencePropertyAttribute.cs
- CharAnimationBase.cs
- OutgoingWebResponseContext.cs
- srgsitem.cs
- XmlDataProvider.cs
- SqlBuffer.cs
- DynamicHyperLink.cs
- OpCellTreeNode.cs
- RecordsAffectedEventArgs.cs
- BindingGroup.cs
- DropShadowBitmapEffect.cs
- XamlTreeBuilder.cs
- WCFModelStrings.Designer.cs
- DeclarativeCatalogPart.cs
- ServerValidateEventArgs.cs
- DataObject.cs
- AffineTransform3D.cs
- GregorianCalendar.cs
- ColorKeyFrameCollection.cs
- DynamicILGenerator.cs
- AuthenticatedStream.cs
- BevelBitmapEffect.cs
- RadioButtonDesigner.cs
- MasterPageBuildProvider.cs
- BooleanStorage.cs
- WebServiceErrorEvent.cs
- WindowsAuthenticationEventArgs.cs
- _UriSyntax.cs
- GeometryModel3D.cs
- WebPartCloseVerb.cs
- CompoundFileReference.cs
- CounterCreationDataCollection.cs
- CustomErrorCollection.cs
- PersonalizationProviderCollection.cs
- XmlWriterDelegator.cs
- HashCodeCombiner.cs
- EventInfo.cs
- ProviderConnectionPoint.cs
- ShaderEffect.cs
- Control.cs
- ContainerControlDesigner.cs
- DataRelation.cs
- Point3DCollectionConverter.cs
- JapaneseLunisolarCalendar.cs
- VisualCollection.cs
- TransformGroup.cs
- XmlSchemaExternal.cs
- DragCompletedEventArgs.cs
- DropShadowBitmapEffect.cs
- ObjectContextServiceProvider.cs
- DrawingBrush.cs
- ButtonChrome.cs
- ConstantSlot.cs
- input.cs
- DiscardableAttribute.cs
- ResourceExpressionBuilder.cs
- ValueTable.cs
- Baml2006ReaderFrame.cs
- DragEvent.cs
- OdbcParameterCollection.cs
- NavigationPropertyAccessor.cs
- GlyphingCache.cs
- DataGridViewCellStyle.cs
- BookmarkScopeInfo.cs
- StringSorter.cs
- ObjectQueryExecutionPlan.cs
- MsmqHostedTransportManager.cs
- Point.cs
- UrlPath.cs
- HttpListenerException.cs
- WebPartsPersonalizationAuthorization.cs
- ChangeNode.cs
- CodeTypeOfExpression.cs
- AnnotationComponentManager.cs
- Rect.cs
- UpdatePanel.cs
- MulticastOption.cs
- DocumentCollection.cs
- DefaultShape.cs
- TdsParserSessionPool.cs
- FormatVersion.cs
- TableLayoutSettings.cs
- SortQuery.cs
- XmlEnumAttribute.cs
- OutOfMemoryException.cs
- DbProviderServices.cs
- OleDbConnectionPoolGroupProviderInfo.cs