Code:
/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / Orcas / QFE / ndp / fx / src / DataWebControls / System / Data / WebControls / WebControlParameterProxy.cs / 1 / 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.ConvertTypeCodeToType( EntityDataSourceUtil.ConvertDbTypeToTypeCode(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()); 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.ConvertTypeCodeToType( EntityDataSourceUtil.ConvertDbTypeToTypeCode(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()); 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
- OracleInfoMessageEventArgs.cs
- SecurityManager.cs
- Monitor.cs
- FieldDescriptor.cs
- AddDataControlFieldDialog.cs
- AuthenticationModuleElementCollection.cs
- ProviderMetadataCachedInformation.cs
- SoapExtensionTypeElementCollection.cs
- ListControl.cs
- followingsibling.cs
- ScriptResourceInfo.cs
- CurrentChangingEventArgs.cs
- XmlReturnWriter.cs
- AutomationPattern.cs
- TraceHandlerErrorFormatter.cs
- StaticTextPointer.cs
- WsatConfiguration.cs
- BufferedWebEventProvider.cs
- SignatureDescription.cs
- NullableConverter.cs
- GeneralTransform3D.cs
- TemplateKey.cs
- ImageListUtils.cs
- ElementHostAutomationPeer.cs
- GridViewCancelEditEventArgs.cs
- SessionIDManager.cs
- TextFragmentEngine.cs
- base64Transforms.cs
- GeometryDrawing.cs
- DesignerTransactionCloseEvent.cs
- WebPartCancelEventArgs.cs
- WebDescriptionAttribute.cs
- FileRegion.cs
- DataGridViewCellCollection.cs
- TextTreeExtractElementUndoUnit.cs
- RegexTypeEditor.cs
- DataServiceExpressionVisitor.cs
- AttributeAction.cs
- HtmlImage.cs
- AlternateView.cs
- EditorZone.cs
- SeekableReadStream.cs
- TimelineClockCollection.cs
- SelectorAutomationPeer.cs
- SecurityDescriptor.cs
- SafeNativeMethods.cs
- shaper.cs
- WindowsClientCredential.cs
- TreeView.cs
- BookmarkCallbackWrapper.cs
- LinearQuaternionKeyFrame.cs
- RC2.cs
- DefaultMergeHelper.cs
- DesignDataSource.cs
- VerificationAttribute.cs
- AdapterUtil.cs
- TypeRefElement.cs
- WhitespaceRuleLookup.cs
- StatusStrip.cs
- DataGridViewComboBoxCell.cs
- AlphabeticalEnumConverter.cs
- RegistryPermission.cs
- ActivityWithResultConverter.cs
- RelationshipEnd.cs
- MouseButton.cs
- XmlSignatureManifest.cs
- DataGridItemEventArgs.cs
- DynamicEntity.cs
- GlyphRunDrawing.cs
- UnhandledExceptionEventArgs.cs
- ImmutableCollection.cs
- WebBrowserBase.cs
- EdmPropertyAttribute.cs
- ResourceContainerWrapper.cs
- MappingException.cs
- AutoFocusStyle.xaml.cs
- LocalsItemDescription.cs
- BCLDebug.cs
- PageParserFilter.cs
- NativeMethods.cs
- Context.cs
- LinkClickEvent.cs
- CommonRemoteMemoryBlock.cs
- PrintController.cs
- Condition.cs
- ToolboxComponentsCreatedEventArgs.cs
- InkCanvasAutomationPeer.cs
- WsatAdminException.cs
- Tuple.cs
- DataGridViewRowPrePaintEventArgs.cs
- HttpBrowserCapabilitiesWrapper.cs
- GridViewCommandEventArgs.cs
- BitVec.cs
- CachedTypeface.cs
- ReachBasicContext.cs
- ReflectPropertyDescriptor.cs
- MultiViewDesigner.cs
- x509store.cs
- Item.cs
- Point3DAnimationUsingKeyFrames.cs