Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / xsp / System / DynamicData / DynamicData / DataSourceUtil.cs / 1305376 / DataSourceUtil.cs
namespace System.Web.DynamicData { using System; using System.Collections.Generic; using System.Globalization; using System.Web.Resources; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; using System.Data; static class DataSourceUtil { private static object s_lock = new object(); private static Dictionarys_typeToTypeCodeMap; internal static TypeCode TypeCodeFromType(Type type) { if (s_typeToTypeCodeMap == null) { lock (s_lock) { if (s_typeToTypeCodeMap == null) { // Dictionary typeNameToTypeCode = new Dictionary (); typeNameToTypeCode[typeof(Boolean)] = TypeCode.Boolean; typeNameToTypeCode[typeof(String)] = TypeCode.String; typeNameToTypeCode[typeof(Byte)] = TypeCode.Byte; typeNameToTypeCode[typeof(Int16)] = TypeCode.Int16; typeNameToTypeCode[typeof(Int32)] = TypeCode.Int32; typeNameToTypeCode[typeof(Int64)] = TypeCode.Int64; typeNameToTypeCode[typeof(Single)] = TypeCode.Single; typeNameToTypeCode[typeof(Double)] = TypeCode.Double; typeNameToTypeCode[typeof(Decimal)] = TypeCode.Decimal; typeNameToTypeCode[typeof(DateTime)] = TypeCode.DateTime; typeNameToTypeCode[typeof(Char)] = TypeCode.Char; // We don't support columns of type 'sqlvariant', which show up as Object // typeNameToTypeCode[typeof(Object)] = TypeCode.DBNull; // We don't support byte arrays. This include columns of type 'timestamp' typeNameToTypeCode[typeof(Byte[])] = TypeCode.DBNull; // Use Object for Guid's (though we need to do some special processing) typeNameToTypeCode[typeof(Guid)] = TypeCode.Object; s_typeToTypeCodeMap = typeNameToTypeCode; } } } // If it's an Nullable , work with T instead type = Misc.RemoveNullableFromType(type); TypeCode typeCode; if (s_typeToTypeCodeMap.TryGetValue(type, out typeCode)) return typeCode; return TypeCode.Object; } internal static void SetParameterTypeCodeAndDbType(Parameter parameter, MetaColumn column) { // If it's a Guid, use a DbType, since TypeCode doesn't support it. For everything else, use TypeCode if (column.ColumnType == typeof(Guid)) { parameter.DbType = DbType.Guid; } else { parameter.Type = column.TypeCode; } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. // Copyright (c) Microsoft Corporation. All rights reserved. namespace System.Web.DynamicData { using System; using System.Collections.Generic; using System.Globalization; using System.Web.Resources; using System.Web.UI; using System.Web.UI.WebControls; using System.Collections; using System.Data; static class DataSourceUtil { private static object s_lock = new object(); private static Dictionary s_typeToTypeCodeMap; internal static TypeCode TypeCodeFromType(Type type) { if (s_typeToTypeCodeMap == null) { lock (s_lock) { if (s_typeToTypeCodeMap == null) { // Dictionary typeNameToTypeCode = new Dictionary (); typeNameToTypeCode[typeof(Boolean)] = TypeCode.Boolean; typeNameToTypeCode[typeof(String)] = TypeCode.String; typeNameToTypeCode[typeof(Byte)] = TypeCode.Byte; typeNameToTypeCode[typeof(Int16)] = TypeCode.Int16; typeNameToTypeCode[typeof(Int32)] = TypeCode.Int32; typeNameToTypeCode[typeof(Int64)] = TypeCode.Int64; typeNameToTypeCode[typeof(Single)] = TypeCode.Single; typeNameToTypeCode[typeof(Double)] = TypeCode.Double; typeNameToTypeCode[typeof(Decimal)] = TypeCode.Decimal; typeNameToTypeCode[typeof(DateTime)] = TypeCode.DateTime; typeNameToTypeCode[typeof(Char)] = TypeCode.Char; // We don't support columns of type 'sqlvariant', which show up as Object // typeNameToTypeCode[typeof(Object)] = TypeCode.DBNull; // We don't support byte arrays. This include columns of type 'timestamp' typeNameToTypeCode[typeof(Byte[])] = TypeCode.DBNull; // Use Object for Guid's (though we need to do some special processing) typeNameToTypeCode[typeof(Guid)] = TypeCode.Object; s_typeToTypeCodeMap = typeNameToTypeCode; } } } // If it's an Nullable , work with T instead type = Misc.RemoveNullableFromType(type); TypeCode typeCode; if (s_typeToTypeCodeMap.TryGetValue(type, out typeCode)) return typeCode; return TypeCode.Object; } internal static void SetParameterTypeCodeAndDbType(Parameter parameter, MetaColumn column) { // If it's a Guid, use a DbType, since TypeCode doesn't support it. For everything else, use TypeCode if (column.ColumnType == typeof(Guid)) { parameter.DbType = DbType.Guid; } else { parameter.Type = column.TypeCode; } } } } // 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
- WebPartCollection.cs
- ConstructorExpr.cs
- AsnEncodedData.cs
- RowSpanVector.cs
- ResourceCategoryAttribute.cs
- SchemaInfo.cs
- TimelineClockCollection.cs
- SetterBase.cs
- NamespaceDecl.cs
- PermissionSetTriple.cs
- GenericTypeParameterBuilder.cs
- AttributedMetaModel.cs
- _CookieModule.cs
- TreeViewHitTestInfo.cs
- XmlRawWriterWrapper.cs
- FlowDocumentPageViewerAutomationPeer.cs
- XPathDocument.cs
- ButtonRenderer.cs
- _StreamFramer.cs
- ByeMessageCD1.cs
- ProfilePropertySettingsCollection.cs
- MetadataPropertyCollection.cs
- EdmComplexTypeAttribute.cs
- ExclusiveCanonicalizationTransform.cs
- querybuilder.cs
- ProfilePropertySettings.cs
- EpmSourceTree.cs
- HwndProxyElementProvider.cs
- WebBrowserContainer.cs
- ModelUIElement3D.cs
- ProjectedSlot.cs
- XPathDescendantIterator.cs
- OutKeywords.cs
- FlowDocumentPage.cs
- TransportContext.cs
- SmiContext.cs
- AVElementHelper.cs
- InputLangChangeEvent.cs
- SqlUserDefinedTypeAttribute.cs
- DoubleLinkListEnumerator.cs
- TcpSocketManager.cs
- RequestSecurityToken.cs
- StrictAndMessageFilter.cs
- FileLevelControlBuilderAttribute.cs
- UnionCodeGroup.cs
- DomainUpDown.cs
- BamlLocalizationDictionary.cs
- ForeignKeyConstraint.cs
- UdpChannelFactory.cs
- ResourceSetExpression.cs
- TypeBrowser.xaml.cs
- DataChangedEventManager.cs
- IUnknownConstantAttribute.cs
- ControlBindingsCollection.cs
- ChannelSinkStacks.cs
- HwndTarget.cs
- MenuItemBindingCollection.cs
- SystemIPGlobalStatistics.cs
- AutoScrollExpandMessageFilter.cs
- CollectionEditor.cs
- CodeAccessSecurityEngine.cs
- Line.cs
- DbConnectionHelper.cs
- ImageCodecInfoPrivate.cs
- ExpressionPrefixAttribute.cs
- TimelineClockCollection.cs
- HwndHostAutomationPeer.cs
- ColumnResizeUndoUnit.cs
- ConfigXmlAttribute.cs
- SecurityVerifiedMessage.cs
- DrawTreeNodeEventArgs.cs
- WindowsSlider.cs
- TcpTransportSecurityElement.cs
- PointAnimationUsingKeyFrames.cs
- VirtualDirectoryMappingCollection.cs
- BooleanExpr.cs
- util.cs
- FolderBrowserDialog.cs
- PaintEvent.cs
- MetabaseSettings.cs
- WebBaseEventKeyComparer.cs
- ComPlusDiagnosticTraceRecords.cs
- DependencyObjectType.cs
- UDPClient.cs
- CqlLexer.cs
- XmlConvert.cs
- AddressHeader.cs
- WCFModelStrings.Designer.cs
- SpecialTypeDataContract.cs
- TargetFrameworkAttribute.cs
- CssClassPropertyAttribute.cs
- NumericUpDownAccelerationCollection.cs
- PackageDigitalSignature.cs
- TrailingSpaceComparer.cs
- QilTernary.cs
- RolePrincipal.cs
- TransactionScope.cs
- PeerToPeerException.cs
- TdsParserSafeHandles.cs
- ParserContext.cs