Code:
/ 4.0 / 4.0 / DEVDIV_TFS / Dev10 / Releases / RTMRel / ndp / fx / src / DataWebControlsDesign / System / Data / WebControls / Design / EntityConnectionStringBuilderItem.cs / 1305376 / EntityConnectionStringBuilderItem.cs
//------------------------------------------------------------------------------ //// Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //----------------------------------------------------------------------------- using System.Data.EntityClient; using System.Diagnostics; namespace System.Web.UI.Design.WebControls { internal class EntityConnectionStringBuilderItem : IComparable{ // Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly. private readonly EntityConnectionStringBuilder _connectionStringBuilder; private readonly string _unknownConnectionString; // used when the string cannot be loaded into a connection string builder or is missing some required keywords internal EntityConnectionStringBuilderItem(EntityConnectionStringBuilder connectionStringBuilder) { // empty connection string builder is allowed, but not null Debug.Assert(connectionStringBuilder != null, "null connectionStringBuilder"); _connectionStringBuilder = connectionStringBuilder; } internal EntityConnectionStringBuilderItem(string unknownConnectionString) { // empty is not allowed -- use the constructor that takes a builder if the string is empty Debug.Assert(!String.IsNullOrEmpty(unknownConnectionString), "null or empty unknownConnectionString"); _unknownConnectionString = unknownConnectionString; } internal string ConnectionString { get { if (_connectionStringBuilder != null) { return _connectionStringBuilder.ConnectionString; } else { return _unknownConnectionString; } } } internal EntityConnectionStringBuilder EntityConnectionStringBuilder { get { return _connectionStringBuilder; } } internal bool IsEmpty { get { return String.IsNullOrEmpty(this.ConnectionString); } } internal bool IsNamedConnection { get { if (_connectionStringBuilder != null) { return !String.IsNullOrEmpty(_connectionStringBuilder.Name); } else { // if the connection string is not recognized by a EntityConnectionStringBuilder, it can't be a valid named connection return false; } } } public override string ToString() { // Display just the name for named connections, but the full connection string otherwise if (_connectionStringBuilder != null) { if (!String.IsNullOrEmpty(_connectionStringBuilder.Name)) { return _connectionStringBuilder.Name; } else { return _connectionStringBuilder.ConnectionString; } } else { return _unknownConnectionString; } } int IComparable .CompareTo(EntityConnectionStringBuilderItem other) { return (String.Compare(this.ToString(), other.ToString(), StringComparison.OrdinalIgnoreCase)); } } } // File provided for Reference Use Only by Microsoft Corporation (c) 2007. //------------------------------------------------------------------------------ // // Copyright (c) Microsoft Corporation. All rights reserved. // // // @owner [....] // @backupOwner [....] //----------------------------------------------------------------------------- using System.Data.EntityClient; using System.Diagnostics; namespace System.Web.UI.Design.WebControls { internal class EntityConnectionStringBuilderItem : IComparable{ // Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly. private readonly EntityConnectionStringBuilder _connectionStringBuilder; private readonly string _unknownConnectionString; // used when the string cannot be loaded into a connection string builder or is missing some required keywords internal EntityConnectionStringBuilderItem(EntityConnectionStringBuilder connectionStringBuilder) { // empty connection string builder is allowed, but not null Debug.Assert(connectionStringBuilder != null, "null connectionStringBuilder"); _connectionStringBuilder = connectionStringBuilder; } internal EntityConnectionStringBuilderItem(string unknownConnectionString) { // empty is not allowed -- use the constructor that takes a builder if the string is empty Debug.Assert(!String.IsNullOrEmpty(unknownConnectionString), "null or empty unknownConnectionString"); _unknownConnectionString = unknownConnectionString; } internal string ConnectionString { get { if (_connectionStringBuilder != null) { return _connectionStringBuilder.ConnectionString; } else { return _unknownConnectionString; } } } internal EntityConnectionStringBuilder EntityConnectionStringBuilder { get { return _connectionStringBuilder; } } internal bool IsEmpty { get { return String.IsNullOrEmpty(this.ConnectionString); } } internal bool IsNamedConnection { get { if (_connectionStringBuilder != null) { return !String.IsNullOrEmpty(_connectionStringBuilder.Name); } else { // if the connection string is not recognized by a EntityConnectionStringBuilder, it can't be a valid named connection return false; } } } public override string ToString() { // Display just the name for named connections, but the full connection string otherwise if (_connectionStringBuilder != null) { if (!String.IsNullOrEmpty(_connectionStringBuilder.Name)) { return _connectionStringBuilder.Name; } else { return _connectionStringBuilder.ConnectionString; } } else { return _unknownConnectionString; } } int IComparable .CompareTo(EntityConnectionStringBuilderItem other) { return (String.Compare(this.ToString(), other.ToString(), StringComparison.OrdinalIgnoreCase)); } } } // 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
- DataGridColumn.cs
- SqlCachedBuffer.cs
- LocatorGroup.cs
- DataGridViewBand.cs
- SystemWebCachingSectionGroup.cs
- ServiceProviders.cs
- Int32Animation.cs
- StylusCaptureWithinProperty.cs
- NavigateUrlConverter.cs
- UpdateTracker.cs
- EntityViewContainer.cs
- CheckedPointers.cs
- ComplexTypeEmitter.cs
- ControlIdConverter.cs
- TagNameToTypeMapper.cs
- CalendarDayButton.cs
- RegexFCD.cs
- StrongTypingException.cs
- WebBrowserPermission.cs
- ProbeDuplexAsyncResult.cs
- FileIOPermission.cs
- CompilerParameters.cs
- XmlILOptimizerVisitor.cs
- HiddenFieldDesigner.cs
- NamespaceQuery.cs
- TextPenaltyModule.cs
- DataReceivedEventArgs.cs
- DataGridTablesFactory.cs
- MaterialGroup.cs
- Scheduling.cs
- unsafeIndexingFilterStream.cs
- CodeSubDirectory.cs
- FamilyCollection.cs
- HostingEnvironmentSection.cs
- SendMailErrorEventArgs.cs
- DataGridViewRowContextMenuStripNeededEventArgs.cs
- WebPartMovingEventArgs.cs
- TreeNodeCollection.cs
- ListChangedEventArgs.cs
- DomainUpDown.cs
- ComponentConverter.cs
- HTMLTextWriter.cs
- documentsequencetextview.cs
- Ipv6Element.cs
- WebRequestModuleElement.cs
- unitconverter.cs
- TableAdapterManagerHelper.cs
- TransformCryptoHandle.cs
- httpapplicationstate.cs
- EntityUtil.cs
- ProxyBuilder.cs
- ContainerParagraph.cs
- PkcsMisc.cs
- ConnectionDemuxer.cs
- CachedFontFamily.cs
- DeferredTextReference.cs
- StringDictionary.cs
- DataViewSettingCollection.cs
- IIS7UserPrincipal.cs
- HttpRequestCacheValidator.cs
- ListBindingHelper.cs
- TextSelectionHelper.cs
- FileAuthorizationModule.cs
- RegisterResponseInfo.cs
- HttpServerVarsCollection.cs
- AttachedPropertyBrowsableAttribute.cs
- Wildcard.cs
- TypographyProperties.cs
- DataRow.cs
- JapaneseCalendar.cs
- UIElementCollection.cs
- KeyNotFoundException.cs
- WindowsSecurityToken.cs
- CollectionMarkupSerializer.cs
- ProfileBuildProvider.cs
- SchemaComplexType.cs
- CompiledQuery.cs
- XmlImplementation.cs
- SiteMapHierarchicalDataSourceView.cs
- Rfc2898DeriveBytes.cs
- PropertyToken.cs
- MailAddress.cs
- Variable.cs
- AttachedProperty.cs
- Overlapped.cs
- SimpleRecyclingCache.cs
- ToggleButtonAutomationPeer.cs
- EntityDescriptor.cs
- ContractAdapter.cs
- PageBreakRecord.cs
- BitmapCodecInfoInternal.cs
- GridViewAutoFormat.cs
- EntityDataSourceValidationException.cs
- SiteMapNode.cs
- WebPartEditVerb.cs
- AlternateView.cs
- FontUnit.cs
- LZCodec.cs
- CriticalFinalizerObject.cs
- SymmetricKeyWrap.cs