1
//------------------------------------------------------------------------------
2 // <copyright file="EntityDataSourceContainerNameItem.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
7 // @backupOwner Microsoft
8 //------------------------------------------------------------------------------
10 using System
.Data
.Metadata
.Edm
;
11 using System
.Diagnostics
;
13 namespace System
.Web
.UI
.Design
.WebControls
15 internal class EntityDataSourceContainerNameItem
: IComparable
<EntityDataSourceContainerNameItem
>
17 // Only one of the following should be set. This is enforced through the constructors and the fact that these fields are readonly.
18 private readonly EntityContainer _entityContainer
; // used when we have a real EntityContainer backing this item
19 private readonly string _unknownContainerName
; // used when we have an unknown DefaultContainerName that we still want to include in the list
21 internal EntityDataSourceContainerNameItem(EntityContainer entityContainer
)
23 Debug
.Assert(entityContainer
!= null, "null entityContainer");
24 _entityContainer
= entityContainer
;
27 internal EntityDataSourceContainerNameItem(string unknownContainerName
)
29 Debug
.Assert(!String
.IsNullOrEmpty(unknownContainerName
), "null or empty unknownContainerName");
30 _unknownContainerName
= unknownContainerName
;
33 internal string EntityContainerName
37 if (_entityContainer
!= null)
39 return _entityContainer
.Name
;
43 return _unknownContainerName
;
48 internal EntityContainer EntityContainer
52 // may be null if this represents an unknown container
53 return _entityContainer
;
57 public override string ToString()
59 return this.EntityContainerName
;
62 int IComparable
<EntityDataSourceContainerNameItem
>.CompareTo(EntityDataSourceContainerNameItem other
)
64 return (String
.Compare(this.EntityContainerName
, other
.EntityContainerName
, StringComparison
.OrdinalIgnoreCase
));