Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / ModelProviders / TableProvider.cs / 1305376 / TableProvider.cs
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Security.Principal;
namespace System.Web.DynamicData.ModelProviders {
///
/// Base provider class for tables.
/// Each provider type (e.g. Linq To Sql, Entity Framework, 3rd party) extends this class.
///
public abstract class TableProvider {
private Type _rootEntityType;
private string _dataContextPropertyName;
internal TableProvider() {
// for unit testing
}
///
/// ctor
///
/// the model this table belongs to
protected TableProvider(DataModelProvider model) {
if (model == null) {
throw new ArgumentNullException("model");
}
DataModel = model;
}
///
/// readable representation
///
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
public override string ToString() {
// To help identifying objects in debugger
return Name ?? base.ToString();
}
///
/// Provides access to attributes defined for the table represented by this provider.
///
public virtual AttributeCollection Attributes {
get {
return GetTypeDescriptor().GetAttributes();
}
}
public virtual ICustomTypeDescriptor GetTypeDescriptor() {
#if ORYX_VNEXT
return MetadataHandlerRegistration.GetTypeDescriptor(EntityType);
#else
return TypeDescriptor.GetProvider(EntityType).GetTypeDescriptor(EntityType);
#endif
}
///
/// The name of the table. Typically, this is the name of the property in the data context class
///
public virtual string Name { get; protected set; }
///
/// The CLR type that represents this table
///
public virtual Type EntityType { get; protected set; }
///
/// The collection of columns in this table
///
public abstract ReadOnlyCollection Columns { get; }
///
/// The IQueryable that returns the elements of this table
///
public abstract IQueryable GetQuery(object context);
///
/// The data model provider that this table is part of
///
public DataModelProvider DataModel { get; internal set; }
///
/// Get the value of a foreign key for a given row. By default, it just looks up a property by that name
///
public virtual object EvaluateForeignKey(object row, string foreignKeyName) {
return System.Web.UI.DataBinder.GetPropertyValue(row, foreignKeyName);
}
///
/// Return the parent type of this entity's inheritance hierarchy; if the type is at the top
/// of an inheritance hierarchy or does not have any inheritance, will return null.
///
public virtual Type ParentEntityType { get; protected set; }
///
/// Return the root type of this entity's inheritance hierarchy; if the type is at the top
/// of an inheritance hierarchy or does not have any inheritance, will return EntityType.
///
public virtual Type RootEntityType {
get {
return _rootEntityType ?? EntityType;
}
protected set {
_rootEntityType = value;
}
}
///
/// Name of table coming from the property on the data context. E.g. the value is "Products" for
/// a table that is part of the NorthwindDataContext.Products collection. If this value has not
/// been set, it will return the value of the Name property.
///
public virtual string DataContextPropertyName {
get {
return _dataContextPropertyName ?? Name;
}
protected set {
_dataContextPropertyName = value;
}
}
///
/// Returns whether the passed in user is allowed to delete items from the table
///
public virtual bool CanDelete(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to insert into the table
///
public virtual bool CanInsert(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to read from the table
///
public virtual bool CanRead(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to make changes tothe table
///
public virtual bool CanUpdate(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
}
}
// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Linq;
using System.Security.Principal;
namespace System.Web.DynamicData.ModelProviders {
///
/// Base provider class for tables.
/// Each provider type (e.g. Linq To Sql, Entity Framework, 3rd party) extends this class.
///
public abstract class TableProvider {
private Type _rootEntityType;
private string _dataContextPropertyName;
internal TableProvider() {
// for unit testing
}
///
/// ctor
///
/// the model this table belongs to
protected TableProvider(DataModelProvider model) {
if (model == null) {
throw new ArgumentNullException("model");
}
DataModel = model;
}
///
/// readable representation
///
///
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Security", "CA2123:OverrideLinkDemandsShouldBeIdenticalToBase")]
public override string ToString() {
// To help identifying objects in debugger
return Name ?? base.ToString();
}
///
/// Provides access to attributes defined for the table represented by this provider.
///
public virtual AttributeCollection Attributes {
get {
return GetTypeDescriptor().GetAttributes();
}
}
public virtual ICustomTypeDescriptor GetTypeDescriptor() {
#if ORYX_VNEXT
return MetadataHandlerRegistration.GetTypeDescriptor(EntityType);
#else
return TypeDescriptor.GetProvider(EntityType).GetTypeDescriptor(EntityType);
#endif
}
///
/// The name of the table. Typically, this is the name of the property in the data context class
///
public virtual string Name { get; protected set; }
///
/// The CLR type that represents this table
///
public virtual Type EntityType { get; protected set; }
///
/// The collection of columns in this table
///
public abstract ReadOnlyCollection Columns { get; }
///
/// The IQueryable that returns the elements of this table
///
public abstract IQueryable GetQuery(object context);
///
/// The data model provider that this table is part of
///
public DataModelProvider DataModel { get; internal set; }
///
/// Get the value of a foreign key for a given row. By default, it just looks up a property by that name
///
public virtual object EvaluateForeignKey(object row, string foreignKeyName) {
return System.Web.UI.DataBinder.GetPropertyValue(row, foreignKeyName);
}
///
/// Return the parent type of this entity's inheritance hierarchy; if the type is at the top
/// of an inheritance hierarchy or does not have any inheritance, will return null.
///
public virtual Type ParentEntityType { get; protected set; }
///
/// Return the root type of this entity's inheritance hierarchy; if the type is at the top
/// of an inheritance hierarchy or does not have any inheritance, will return EntityType.
///
public virtual Type RootEntityType {
get {
return _rootEntityType ?? EntityType;
}
protected set {
_rootEntityType = value;
}
}
///
/// Name of table coming from the property on the data context. E.g. the value is "Products" for
/// a table that is part of the NorthwindDataContext.Products collection. If this value has not
/// been set, it will return the value of the Name property.
///
public virtual string DataContextPropertyName {
get {
return _dataContextPropertyName ?? Name;
}
protected set {
_dataContextPropertyName = value;
}
}
///
/// Returns whether the passed in user is allowed to delete items from the table
///
public virtual bool CanDelete(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to insert into the table
///
public virtual bool CanInsert(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to read from the table
///
public virtual bool CanRead(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
///
/// Returns whether the passed in user is allowed to make changes tothe table
///
public virtual bool CanUpdate(IPrincipal principal) {
if (principal == null) {
throw new ArgumentNullException("principal");
}
return true;
}
}
}
// 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
- VariableQuery.cs
- ZipIOLocalFileBlock.cs
- RoleService.cs
- SimpleTypeResolver.cs
- ToolStripPanelCell.cs
- Vector3DCollection.cs
- DesignerActionUIStateChangeEventArgs.cs
- AssociationTypeEmitter.cs
- XmlAttribute.cs
- MetadataItemCollectionFactory.cs
- CompatibleIComparer.cs
- ClientSettingsStore.cs
- PopupRootAutomationPeer.cs
- XXXOnTypeBuilderInstantiation.cs
- Fonts.cs
- M3DUtil.cs
- MeasurementDCInfo.cs
- DispatcherSynchronizationContext.cs
- ScriptingRoleServiceSection.cs
- DataGridViewDataConnection.cs
- CategoryGridEntry.cs
- DeviceContexts.cs
- TrackingStringDictionary.cs
- SessionState.cs
- TextEditorLists.cs
- ObjectReaderCompiler.cs
- HotSpot.cs
- RuntimeIdentifierPropertyAttribute.cs
- SqlTriggerAttribute.cs
- ApplicationSettingsBase.cs
- dtdvalidator.cs
- SerialPort.cs
- unsafeIndexingFilterStream.cs
- WebPart.cs
- WindowsAltTab.cs
- ByteAnimationUsingKeyFrames.cs
- Matrix3DConverter.cs
- ReadOnlyTernaryTree.cs
- LinkTarget.cs
- CodeExpressionRuleDeclaration.cs
- SiteMapNodeCollection.cs
- StyleHelper.cs
- SystemThemeKey.cs
- SchemaMapping.cs
- WebPartConnectionsConnectVerb.cs
- xmlglyphRunInfo.cs
- Rect3DConverter.cs
- ActiveXContainer.cs
- PresentationSource.cs
- UnmanagedMarshal.cs
- OrderingExpression.cs
- RightsManagementEncryptedStream.cs
- XsltFunctions.cs
- TextTreeExtractElementUndoUnit.cs
- TrustSection.cs
- BezierSegment.cs
- AssemblyResourceLoader.cs
- FontWeights.cs
- QueuedDeliveryRequirementsMode.cs
- ContentControl.cs
- TreeViewImageKeyConverter.cs
- SqlFlattener.cs
- XamlStyleSerializer.cs
- ClientSettingsStore.cs
- BevelBitmapEffect.cs
- ChooseAction.cs
- SSmlParser.cs
- XmlSchemaNotation.cs
- Baml2006ReaderFrame.cs
- SamlAssertion.cs
- Rotation3DAnimationBase.cs
- HighlightComponent.cs
- Enlistment.cs
- FormViewActionList.cs
- PropertyToken.cs
- DWriteFactory.cs
- RSAPKCS1SignatureDeformatter.cs
- XmlWellformedWriter.cs
- RequestTimeoutManager.cs
- TemplateColumn.cs
- SplashScreenNativeMethods.cs
- DataTablePropertyDescriptor.cs
- EventProxy.cs
- RemoteWebConfigurationHost.cs
- ToolStripComboBox.cs
- Misc.cs
- MediaPlayer.cs
- Filter.cs
- OutputWindow.cs
- CompletionCallbackWrapper.cs
- WebPartVerbCollection.cs
- ConfigXmlElement.cs
- DesignerDataTable.cs
- WindowsSecurityToken.cs
- UnmanagedHandle.cs
- IMembershipProvider.cs
- GridViewCommandEventArgs.cs
- UniqueEventHelper.cs
- TemplateComponentConnector.cs
- FaultDescription.cs