Code:
/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / WebForms / System / Web / UI / Design / TypeFieldSchema.cs / 1 / TypeFieldSchema.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // //----------------------------------------------------------------------------- namespace System.Web.UI.Design { using System; using System.Collections; using System.ComponentModel; using System.Diagnostics; using System.Reflection; ////// Represents a field's schema based on a PropertyDescriptor object. /// This is used by the TypeSchema class to provide schema for arbitrary types. /// If the property has the DataObjectFieldAttribute then it is used to get /// additional information about the field. /// [System.Security.Permissions.SecurityPermission(System.Security.Permissions.SecurityAction.Demand, Flags = System.Security.Permissions.SecurityPermissionFlag.UnmanagedCode)] internal sealed class TypeFieldSchema : IDataSourceFieldSchema { private PropertyDescriptor _fieldDescriptor; private bool _retrievedMetaData; private bool _primaryKey; private bool _isIdentity; private bool _isNullable; private int _length = -1; public TypeFieldSchema(PropertyDescriptor fieldDescriptor) { if (fieldDescriptor == null) { throw new ArgumentNullException("fieldDescriptor"); } _fieldDescriptor = fieldDescriptor; } public Type DataType { get { // If the type is Nullablethen we just want the T Type type = _fieldDescriptor.PropertyType; if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(Nullable<>))) { return type.GetGenericArguments()[0]; } return type; } } public bool Identity { get { EnsureMetaData(); return _isIdentity; } } public bool IsReadOnly { get { return _fieldDescriptor.IsReadOnly; } } public bool IsUnique { get { return false; } } public int Length { get { EnsureMetaData(); return _length; } } public string Name { get { return _fieldDescriptor.Name; } } public bool Nullable { get { // All reference types are nullable, and value types wrapped // in Nullable<> are nullable too. EnsureMetaData(); Type type = _fieldDescriptor.PropertyType; return (!type.IsValueType) || _isNullable || (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(Nullable<>))); } } public int Precision { get { return -1; } } public bool PrimaryKey { get { EnsureMetaData(); return _primaryKey; } } public int Scale { get { return -1; } } private void EnsureMetaData() { if (_retrievedMetaData) { return; } DataObjectFieldAttribute attr = (DataObjectFieldAttribute)_fieldDescriptor.Attributes[typeof(DataObjectFieldAttribute)]; if (attr != null) { _primaryKey = attr.PrimaryKey; _isIdentity = attr.IsIdentity; _isNullable = attr.IsNullable; _length = attr.Length; } _retrievedMetaData = 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
- ParseElement.cs
- DataGridColumnCollection.cs
- JoinSymbol.cs
- Validator.cs
- ListenerConnectionModeReader.cs
- QueryAccessibilityHelpEvent.cs
- __Filters.cs
- control.ime.cs
- ColorConvertedBitmap.cs
- HttpHandlerActionCollection.cs
- SimpleHandlerBuildProvider.cs
- SizeIndependentAnimationStorage.cs
- RegexCompilationInfo.cs
- TransformerInfoCollection.cs
- ResXFileRef.cs
- LogManagementAsyncResult.cs
- XPathChildIterator.cs
- WebPartConnectionCollection.cs
- DataSourceView.cs
- UserUseLicenseDictionaryLoader.cs
- BypassElement.cs
- ZoneLinkButton.cs
- OracleCommand.cs
- VectorKeyFrameCollection.cs
- CallbackDebugElement.cs
- Span.cs
- XmlObjectSerializerWriteContextComplexJson.cs
- SerialPort.cs
- BitmapEffect.cs
- AppSettingsReader.cs
- KerberosSecurityTokenProvider.cs
- TraceSection.cs
- FeatureSupport.cs
- PagesChangedEventArgs.cs
- HuffCodec.cs
- PerspectiveCamera.cs
- ToolStripInSituService.cs
- ListBindableAttribute.cs
- EdmItemError.cs
- AppSecurityManager.cs
- TreeViewItem.cs
- Set.cs
- LinearKeyFrames.cs
- ViewValidator.cs
- CodeSnippetExpression.cs
- Internal.cs
- RectangleHotSpot.cs
- ObjectIDGenerator.cs
- BufferModeSettings.cs
- ElementMarkupObject.cs
- UIElementParagraph.cs
- HybridObjectCache.cs
- Trace.cs
- messageonlyhwndwrapper.cs
- ConfigurationSectionGroup.cs
- NamedElement.cs
- StagingAreaInputItem.cs
- BamlLocalizer.cs
- DocumentViewerAutomationPeer.cs
- RectangleHotSpot.cs
- GetChildSubtree.cs
- ExitEventArgs.cs
- AppDomainProtocolHandler.cs
- BaseComponentEditor.cs
- ResourcePermissionBase.cs
- InstancePersistenceEvent.cs
- FixedDocument.cs
- SoapProcessingBehavior.cs
- SQLInt64.cs
- InOutArgumentConverter.cs
- ProfessionalColorTable.cs
- RotateTransform.cs
- Point3DConverter.cs
- HttpContextWrapper.cs
- ExceptionValidationRule.cs
- WinEventWrap.cs
- FontStyles.cs
- EmbeddedMailObjectsCollection.cs
- TimeSpanStorage.cs
- VolatileEnlistmentMultiplexing.cs
- DrawingContextWalker.cs
- FrameworkContentElement.cs
- BitmapImage.cs
- CornerRadiusConverter.cs
- ByteAnimationBase.cs
- MimeMapping.cs
- TabItemWrapperAutomationPeer.cs
- CatalogPartCollection.cs
- RowToFieldTransformer.cs
- FrameSecurityDescriptor.cs
- DocumentOrderQuery.cs
- ProfileProvider.cs
- BypassElement.cs
- SchemaNamespaceManager.cs
- WebPartPersonalization.cs
- RepeaterItemEventArgs.cs
- EventKeyword.cs
- StringCollection.cs
- RtfNavigator.cs
- PixelFormat.cs