Code:
/ Dotnetfx_Win7_3.5.1 / Dotnetfx_Win7_3.5.1 / 3.5.1 / DEVDIV / depot / DevDiv / releases / Orcas / NetFXw7 / 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
- PeerContact.cs
- MediaEntryAttribute.cs
- KeyConverter.cs
- ContextBase.cs
- Cursor.cs
- TextEditorParagraphs.cs
- TextEndOfParagraph.cs
- InfoCardSymmetricAlgorithm.cs
- HtmlWindow.cs
- BlockCollection.cs
- WorkflowMarkupSerializationManager.cs
- AssemblyAttributes.cs
- filewebresponse.cs
- UriTemplateTable.cs
- Fx.cs
- StatusBarAutomationPeer.cs
- SafeCancelMibChangeNotify.cs
- PriorityBinding.cs
- CapabilitiesAssignment.cs
- PartDesigner.cs
- MimeMultiPart.cs
- HttpProcessUtility.cs
- TrackingStringDictionary.cs
- XmlSerializableServices.cs
- IxmlLineInfo.cs
- SafeThemeHandle.cs
- COMException.cs
- SetterBaseCollection.cs
- XmlSortKeyAccumulator.cs
- SymmetricCryptoHandle.cs
- RuntimeConfig.cs
- DependencyObject.cs
- PolyQuadraticBezierSegment.cs
- UIHelper.cs
- Debug.cs
- DbDataRecord.cs
- FrameworkRichTextComposition.cs
- TreeBuilderXamlTranslator.cs
- DictationGrammar.cs
- SqlMetaData.cs
- HtmlControlAdapter.cs
- AuthenticatingEventArgs.cs
- BitmapCodecInfo.cs
- ActivityExecutorDelegateInfo.cs
- CustomErrorsSection.cs
- GrammarBuilderRuleRef.cs
- FilterException.cs
- LowerCaseStringConverter.cs
- MailMessageEventArgs.cs
- Scheduler.cs
- StyleXamlParser.cs
- NextPreviousPagerField.cs
- ListViewItem.cs
- DataDesignUtil.cs
- XmlHierarchicalDataSourceView.cs
- MdbDataFileEditor.cs
- CriticalExceptions.cs
- OutputWindow.cs
- _ShellExpression.cs
- CacheEntry.cs
- HtmlInputReset.cs
- BitmapEffect.cs
- URL.cs
- TextEditorSpelling.cs
- BasicViewGenerator.cs
- IFlowDocumentViewer.cs
- FormsIdentity.cs
- AvtEvent.cs
- CfgParser.cs
- XsltConvert.cs
- Int16AnimationBase.cs
- DefaultHttpHandler.cs
- Triplet.cs
- SelectionBorderGlyph.cs
- XmlBinaryReader.cs
- ProjectionNode.cs
- ListSourceHelper.cs
- TextTreeInsertElementUndoUnit.cs
- ParagraphResult.cs
- BasicExpandProvider.cs
- CredentialCache.cs
- WorkflowValidationFailedException.cs
- WindowsScroll.cs
- SafeSystemMetrics.cs
- MessagingDescriptionAttribute.cs
- Comparer.cs
- WpfXamlType.cs
- Menu.cs
- SqlConnectionHelper.cs
- UserControl.cs
- DocumentSchemaValidator.cs
- DefaultValueAttribute.cs
- SmtpSpecifiedPickupDirectoryElement.cs
- WsdlServiceChannelBuilder.cs
- iisPickupDirectory.cs
- WindowsProgressbar.cs
- KnownTypesHelper.cs
- XmlQueryTypeFactory.cs
- DataTableNewRowEvent.cs
- TextTreeRootNode.cs