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
- SoapAttributeAttribute.cs
- Certificate.cs
- CryptoProvider.cs
- UnsettableComboBox.cs
- SHA256.cs
- DataRowComparer.cs
- _TLSstream.cs
- XsltQilFactory.cs
- StrokeSerializer.cs
- LockCookie.cs
- Script.cs
- AuthorizationContext.cs
- NameNode.cs
- DataReaderContainer.cs
- COM2ComponentEditor.cs
- WebPartPersonalization.cs
- HandlerBase.cs
- XmlSerializationGeneratedCode.cs
- hebrewshape.cs
- WebServiceReceive.cs
- InvokeDelegate.cs
- DecoderBestFitFallback.cs
- InvalidWorkflowException.cs
- SvcMapFileSerializer.cs
- GenerateHelper.cs
- WindowsFormsSynchronizationContext.cs
- SerializeAbsoluteContext.cs
- FontCollection.cs
- PtsPage.cs
- CalendarTable.cs
- XmlAnyAttributeAttribute.cs
- ShapeTypeface.cs
- IndependentlyAnimatedPropertyMetadata.cs
- DbParameterCollectionHelper.cs
- Repeater.cs
- TargetConverter.cs
- PreservationFileWriter.cs
- TypeSystemHelpers.cs
- XmlReflectionImporter.cs
- SelectionWordBreaker.cs
- EntityCommandExecutionException.cs
- ContractHandle.cs
- HtmlTableRowCollection.cs
- FileSystemEventArgs.cs
- ServiceModelExtensionElement.cs
- PartialList.cs
- CheckBoxStandardAdapter.cs
- _FixedSizeReader.cs
- Missing.cs
- ProxyManager.cs
- ToolStripProgressBar.cs
- FrameworkObject.cs
- NameNode.cs
- AssemblyName.cs
- _FtpDataStream.cs
- MarginsConverter.cs
- CacheOutputQuery.cs
- ViewCellSlot.cs
- OSFeature.cs
- SqlGenericUtil.cs
- FontUnit.cs
- InputLangChangeEvent.cs
- validationstate.cs
- SqlClientMetaDataCollectionNames.cs
- XmlDictionaryReaderQuotas.cs
- IsolationInterop.cs
- MergeFilterQuery.cs
- RepeatBehavior.cs
- TraceSection.cs
- ListBindingConverter.cs
- _LocalDataStoreMgr.cs
- BatchStream.cs
- JsonCollectionDataContract.cs
- ExeConfigurationFileMap.cs
- oledbmetadatacolumnnames.cs
- WebServiceErrorEvent.cs
- SemaphoreSlim.cs
- DataSourceCollectionBase.cs
- TraceXPathNavigator.cs
- DocumentPageHost.cs
- ExtendLockAsyncResult.cs
- StackOverflowException.cs
- AsyncResult.cs
- MetabaseServerConfig.cs
- TypedDatasetGenerator.cs
- HttpBindingExtension.cs
- ScriptResourceInfo.cs
- ColumnHeaderConverter.cs
- WindowsFormsEditorServiceHelper.cs
- WebInvokeAttribute.cs
- ProcessHost.cs
- TextEmbeddedObject.cs
- HttpConfigurationContext.cs
- ServiceEndpointCollection.cs
- ListViewCommandEventArgs.cs
- DescendentsWalkerBase.cs
- SrgsRulesCollection.cs
- SamlAttribute.cs
- EventManager.cs
- ServiceModelTimeSpanValidator.cs