Code:
/ DotNET / DotNET / 8.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
- MarkupProperty.cs
- ConsoleKeyInfo.cs
- SqlDependency.cs
- LogConverter.cs
- BrushMappingModeValidation.cs
- PropertyItem.cs
- EnumCodeDomSerializer.cs
- EventWaitHandle.cs
- XmlSchemaAny.cs
- OrderPreservingMergeHelper.cs
- elementinformation.cs
- BevelBitmapEffect.cs
- BooleanFunctions.cs
- WorkflowHostingResponseContext.cs
- DBCommand.cs
- DataGridViewBand.cs
- TextInfo.cs
- BinaryFormatter.cs
- DesignTimeParseData.cs
- X509ChainElement.cs
- FlowchartDesignerCommands.cs
- RenderingBiasValidation.cs
- CodeMemberProperty.cs
- Quad.cs
- followingquery.cs
- ColorDialog.cs
- BufferedGraphics.cs
- ApplicationProxyInternal.cs
- DataGridColumnCollectionEditor.cs
- ProcessHostFactoryHelper.cs
- MailAddressCollection.cs
- MsmqTransportBindingElement.cs
- LexicalChunk.cs
- FormViewActionList.cs
- MessageDecoder.cs
- ExpandedWrapper.cs
- ListViewCancelEventArgs.cs
- StoryFragments.cs
- SmtpTransport.cs
- Events.cs
- DataColumnChangeEvent.cs
- StringWriter.cs
- ConfigurationSectionCollection.cs
- Point3DAnimation.cs
- SQLBinaryStorage.cs
- DistributedTransactionPermission.cs
- FacetValueContainer.cs
- SystemIcmpV4Statistics.cs
- BaseComponentEditor.cs
- _OverlappedAsyncResult.cs
- ExpressionBuilderCollection.cs
- HtmlInputFile.cs
- WSDualHttpSecurityElement.cs
- RoleBoolean.cs
- RectangleF.cs
- DataControlFieldTypeEditor.cs
- BulletedListEventArgs.cs
- MenuBase.cs
- Parser.cs
- ReferenceConverter.cs
- NumberSubstitution.cs
- TableLayout.cs
- Menu.cs
- BitmapEffectInput.cs
- DataGridAddNewRow.cs
- ObjRef.cs
- XmlUnspecifiedAttribute.cs
- Manipulation.cs
- Vector3DKeyFrameCollection.cs
- StackSpiller.Bindings.cs
- BoundField.cs
- PageFunction.cs
- FontStretch.cs
- ObjectReaderCompiler.cs
- LightweightCodeGenerator.cs
- Misc.cs
- DockAndAnchorLayout.cs
- SequentialUshortCollection.cs
- TextEditorCharacters.cs
- FormsAuthenticationUserCollection.cs
- InstanceDataCollection.cs
- JpegBitmapDecoder.cs
- GeometryCombineModeValidation.cs
- SaveFileDialog.cs
- IdentityModelStringsVersion1.cs
- Debugger.cs
- ColumnCollection.cs
- LinkedResourceCollection.cs
- WebColorConverter.cs
- GenerateTemporaryTargetAssembly.cs
- NullExtension.cs
- CatalogZone.cs
- BuildManager.cs
- SimpleBitVector32.cs
- ElasticEase.cs
- StatusBarItemAutomationPeer.cs
- XPathDocumentBuilder.cs
- ToggleButton.cs
- DbModificationCommandTree.cs
- TextMarkerSource.cs