Code:
/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWebControls / System / Data / WebControls / WebControlParameterProxy.cs / 1305376 / WebControlParameterProxy.cs
//---------------------------------------------------------------------- //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner objsdev //--------------------------------------------------------------------- using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web.UI.WebControls; using System.Diagnostics; using System.Data; using System.Globalization; namespace System.Web.UI.WebControls { internal class WebControlParameterProxy { ParameterCollection _collection; EntityDataSource _entityDataSource; Parameter _parameter; // Can be null, that's why this class doesn't subclass Parameter internal WebControlParameterProxy(string propertyName, ParameterCollection parameterCollection, EntityDataSource entityDataSource) { Debug.Assert(null != entityDataSource); Debug.Assert(!String.IsNullOrEmpty(propertyName)); _parameter = EntityDataSourceUtil.GetParameter(propertyName, parameterCollection); _collection = parameterCollection; _entityDataSource = entityDataSource; VerifyUniqueType(_parameter); } internal WebControlParameterProxy(Parameter parameter, ParameterCollection parameterCollection, EntityDataSource entityDataSource) { Debug.Assert(null != entityDataSource); _parameter = parameter; _collection = parameterCollection; _entityDataSource = entityDataSource; VerifyUniqueType(_parameter); } internal string Name { get { if (null != _parameter) { return _parameter.Name; } return null; } } internal bool HasValue { get { return null != _parameter && null != Value; } } internal bool ConvertEmptyStringToNull { get { if (null != _parameter) { return _parameter.ConvertEmptyStringToNull; } return false; } } internal TypeCode TypeCode { get { if (null != _parameter) { return _parameter.Type; } return TypeCode.Empty; } } internal DbType DbType { get { if (null != _parameter) { return _parameter.DbType; } return DbType.Object; } } internal Type ClrType { get { Debug.Assert(this.TypeCode != TypeCode.Empty || this.DbType != DbType.Object, "Need to have TypeCode or DbType to get a ClrType"); if (this.TypeCode != TypeCode.Empty) { return EntityDataSourceUtil.ConvertTypeCodeToType(this.TypeCode); } return EntityDataSourceUtil.ConvertDbTypeToType(this.DbType); } } internal object Value { get { if (_parameter != null) { object paramValue = EntityDataSourceUtil.GetParameterValue(_parameter.Name, _collection, _entityDataSource); if (paramValue != null) { if (this.DbType == DbType.DateTimeOffset) { object value = (paramValue is DateTimeOffset) ? paramValue : DateTimeOffset.Parse(this.Value.ToString(), CultureInfo.CurrentCulture); return value; } else if (this.DbType == DbType.Time) { object value = (paramValue is TimeSpan) ? paramValue : TimeSpan.Parse(paramValue.ToString(), CultureInfo.CurrentCulture); return value; } else if (this.DbType == DbType.Guid) { object value = (paramValue is Guid) ? paramValue : new Guid(paramValue.ToString()); return value; } } return paramValue; } return null; } } private static void VerifyUniqueType(Parameter parameter) { if (parameter != null && parameter.Type == TypeCode.Empty && parameter.DbType == DbType.Object) { throw new InvalidOperationException(Strings.WebControlParameterProxy_TypeDbTypeMutuallyExclusive); } if (parameter != null && parameter.DbType != DbType.Object && parameter.Type != TypeCode.Empty) { throw new InvalidOperationException(Strings.WebControlParameterProxy_TypeDbTypeMutuallyExclusive); } } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007.
Link Menu

This book is available now!
Buy at Amazon US or
Buy at Amazon UK
- TTSEngineProxy.cs
- StreamSecurityUpgradeAcceptor.cs
- DBSqlParserTableCollection.cs
- ReceiveReply.cs
- SettingsPropertyValueCollection.cs
- Executor.cs
- ImageListImage.cs
- JoinGraph.cs
- InkSerializer.cs
- DesignerHelpers.cs
- RelationshipEnd.cs
- ControlTemplate.cs
- CodeDOMUtility.cs
- AppDomainCompilerProxy.cs
- ImpersonateTokenRef.cs
- SqlInfoMessageEvent.cs
- EventRouteFactory.cs
- ClrPerspective.cs
- ThreadPool.cs
- CssTextWriter.cs
- EndpointInstanceProvider.cs
- FlowLayout.cs
- Int32AnimationBase.cs
- StatusBarPanelClickEvent.cs
- ListViewInsertedEventArgs.cs
- _SecureChannel.cs
- TransformConverter.cs
- TextureBrush.cs
- CurrentChangedEventManager.cs
- PrimitiveDataContract.cs
- GenericNameHandler.cs
- RectAnimationClockResource.cs
- Membership.cs
- DelegateCompletionCallbackWrapper.cs
- WindowManager.cs
- NavigationCommands.cs
- OrderPreservingPipeliningSpoolingTask.cs
- ComponentEvent.cs
- SqlGenericUtil.cs
- DBAsyncResult.cs
- ToolStripContextMenu.cs
- Matrix3D.cs
- DefaultTextStoreTextComposition.cs
- EntityReference.cs
- DataGridViewButtonColumn.cs
- AssemblyHash.cs
- MetaColumn.cs
- EncryptedData.cs
- ConfigXmlElement.cs
- PageRanges.cs
- CodeTypeConstructor.cs
- MaskedTextBox.cs
- ProbeMatchesMessageCD1.cs
- HandledEventArgs.cs
- UnsafeNativeMethods.cs
- HttpFileCollection.cs
- MediaTimeline.cs
- CheckPair.cs
- METAHEADER.cs
- ToolStripDropDown.cs
- RegexInterpreter.cs
- PenContexts.cs
- IntSecurity.cs
- WebPartRestoreVerb.cs
- DataRowCollection.cs
- HtmlAnchor.cs
- NodeFunctions.cs
- DataReaderContainer.cs
- IsolatedStorageFilePermission.cs
- BaseTreeIterator.cs
- PartialTrustVisibleAssembliesSection.cs
- TemplateBindingExpressionConverter.cs
- ByteArrayHelperWithString.cs
- MouseEventArgs.cs
- SmiEventStream.cs
- SourceFileInfo.cs
- SQLChars.cs
- DefaultValueTypeConverter.cs
- KoreanLunisolarCalendar.cs
- Char.cs
- DetailsViewRow.cs
- SocketAddress.cs
- ProcessRequestArgs.cs
- ControlBuilderAttribute.cs
- HMAC.cs
- XmlSerializationWriter.cs
- MetaForeignKeyColumn.cs
- CopyCodeAction.cs
- FilterQuery.cs
- ObjectDataSourceDesigner.cs
- SmtpSection.cs
- PropertyTabAttribute.cs
- EdmConstants.cs
- DataTableExtensions.cs
- JapaneseLunisolarCalendar.cs
- CompositeDataBoundControl.cs
- CollectionViewGroup.cs
- CollectionsUtil.cs
- regiisutil.cs
- HtmlInputSubmit.cs