Code:
/ 4.0 / 4.0 / 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. //---------------------------------------------------------------------- //// 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
- FormViewDeleteEventArgs.cs
- XmlNodeChangedEventArgs.cs
- SharedStream.cs
- JoinTreeSlot.cs
- shaperfactoryquerycacheentry.cs
- AppearanceEditorPart.cs
- WebPartManager.cs
- Mutex.cs
- DataObjectMethodAttribute.cs
- ObjectDataSourceMethodEditor.cs
- PageRequestManager.cs
- ColumnResult.cs
- ItemMap.cs
- TextRange.cs
- ScriptHandlerFactory.cs
- MissingFieldException.cs
- SystemIPInterfaceStatistics.cs
- SelectionItemPattern.cs
- Padding.cs
- CodeEntryPointMethod.cs
- DeviceFilterEditorDialog.cs
- XhtmlBasicLiteralTextAdapter.cs
- FacetChecker.cs
- RewritingProcessor.cs
- IdentityHolder.cs
- Exceptions.cs
- CustomExpressionEventArgs.cs
- SqlGenericUtil.cs
- QueryFunctions.cs
- EFTableProvider.cs
- OpCodes.cs
- XmlNodeChangedEventManager.cs
- SQLRoleProvider.cs
- SchemaImporterExtensionsSection.cs
- DesignerRegion.cs
- XPathDocumentNavigator.cs
- TypeDescriptionProviderAttribute.cs
- WmlPanelAdapter.cs
- ToolStripContainerDesigner.cs
- PrintDialogException.cs
- NamedPipeActivation.cs
- PnrpPermission.cs
- CaseExpr.cs
- EdmFunction.cs
- DefaultTraceListener.cs
- SecurityManager.cs
- ItemCheckedEvent.cs
- TextDocumentView.cs
- InkPresenterAutomationPeer.cs
- SecurityTokenException.cs
- PolicyManager.cs
- SiteMapNodeCollection.cs
- ListBase.cs
- SqlDataSourceCommandEventArgs.cs
- NavigationHelper.cs
- MemoryRecordBuffer.cs
- Propagator.cs
- RotationValidation.cs
- Unit.cs
- SystemKeyConverter.cs
- WeakReference.cs
- TypeDescriptor.cs
- ProcessModelInfo.cs
- Char.cs
- RealProxy.cs
- NameValuePair.cs
- WinEventHandler.cs
- Style.cs
- XmlIterators.cs
- DocumentGridContextMenu.cs
- MimeWriter.cs
- InternalResources.cs
- SortDescriptionCollection.cs
- SchemaCollectionCompiler.cs
- ManagedIStream.cs
- CodeCastExpression.cs
- BaseAddressPrefixFilterElement.cs
- WebReference.cs
- XmlReturnWriter.cs
- RenderCapability.cs
- RegistrationServices.cs
- BezierSegment.cs
- SecurityTokenRequirement.cs
- TcpTransportElement.cs
- FileLevelControlBuilderAttribute.cs
- XmlDocumentViewSchema.cs
- ActivityDefaults.cs
- GifBitmapEncoder.cs
- RepeatButtonAutomationPeer.cs
- DbProviderFactories.cs
- Vector.cs
- InsufficientMemoryException.cs
- MenuItemCollectionEditor.cs
- SessionPageStateSection.cs
- QuotedPrintableStream.cs
- ExpressionNode.cs
- ProtocolsConfigurationEntry.cs
- Repeater.cs
- GeometryCollection.cs
- ObjectDataSourceSelectingEventArgs.cs