Code:
/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / Orcas / SP / 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
- SerTrace.cs
- Ticks.cs
- Wizard.cs
- Vector3DAnimation.cs
- DataViewSetting.cs
- FirstMatchCodeGroup.cs
- FormatPage.cs
- RootContext.cs
- DelegateArgument.cs
- HtmlTernaryTree.cs
- Encoder.cs
- FamilyCollection.cs
- SqlColumnizer.cs
- XamlParser.cs
- HtmlTableRow.cs
- ResourcesChangeInfo.cs
- Int32AnimationUsingKeyFrames.cs
- StrokeCollectionConverter.cs
- Int64.cs
- EdmComplexTypeAttribute.cs
- SymbolPair.cs
- ToolStripDropDown.cs
- TransportSecurityHelpers.cs
- clipboard.cs
- Compress.cs
- ToolBar.cs
- CookieParameter.cs
- Tile.cs
- SiteMapHierarchicalDataSourceView.cs
- HtmlTableRow.cs
- TreeNodeBinding.cs
- MethodToken.cs
- _Connection.cs
- CryptoApi.cs
- OrElse.cs
- Viewport3DVisual.cs
- ClientSettingsProvider.cs
- DataGridViewColumnEventArgs.cs
- CodeTryCatchFinallyStatement.cs
- AssertFilter.cs
- ProvidePropertyAttribute.cs
- SafeCertificateContext.cs
- ClientRolePrincipal.cs
- PartialCachingControl.cs
- DataServiceConfiguration.cs
- SymDocumentType.cs
- FileDetails.cs
- XamlParser.cs
- SecurityResources.cs
- Visitor.cs
- KoreanCalendar.cs
- WriteLine.cs
- Properties.cs
- TextBoxLine.cs
- ConditionChanges.cs
- HitTestParameters3D.cs
- SingleObjectCollection.cs
- DataServiceKeyAttribute.cs
- FloaterParaClient.cs
- TableChangeProcessor.cs
- OrderedDictionary.cs
- ScriptManagerProxy.cs
- InstanceCreationEditor.cs
- WebPartCloseVerb.cs
- CharacterMetrics.cs
- TextContainerChangedEventArgs.cs
- CodeNamespaceCollection.cs
- PropertyGeneratedEventArgs.cs
- WebEvents.cs
- SafeFindHandle.cs
- SharedDp.cs
- ListViewGroupConverter.cs
- BackgroundFormatInfo.cs
- PreservationFileReader.cs
- DesignerWidgets.cs
- View.cs
- ServicePoint.cs
- QueryPrefixOp.cs
- DBConnection.cs
- ParserOptions.cs
- DataSourceView.cs
- FlowDocument.cs
- OSEnvironmentHelper.cs
- SendingRequestEventArgs.cs
- DataGridViewAccessibleObject.cs
- EntitySqlQueryCacheKey.cs
- ExpressionPrefixAttribute.cs
- ServiceParser.cs
- DataRecordInternal.cs
- BamlResourceDeserializer.cs
- TextDecorationCollection.cs
- EqualityComparer.cs
- PeerCollaborationPermission.cs
- CodeExporter.cs
- WmlFormAdapter.cs
- HashJoinQueryOperatorEnumerator.cs
- TableLayout.cs
- InplaceBitmapMetadataWriter.cs
- LinqDataSourceContextEventArgs.cs
- SmtpCommands.cs