1 //------------------------------------------------------------------------------
2 // <copyright file="EntityDataSourceContainerNameConverter.cs" company="Microsoft">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
8 //------------------------------------------------------------------------------
10 using System.Collections.Generic;
11 using System.ComponentModel;
12 using System.ComponentModel.Design;
13 using System.Diagnostics;
14 using System.Web.UI.WebControls;
16 namespace System.Web.UI.Design.WebControls
18 internal class EntityDataSourceContainerNameConverter : StringConverter
21 public EntityDataSourceContainerNameConverter()
26 public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
28 // We can only get a list of possible DefaultContainerName values if we have:
29 // (1) Connection string so we can load metadata
30 // Even if this value is set, it may not be possible to actually load the metadata, but at least we can try the lookup if requested
32 EntityDataSource entityDataSource = context.Instance as EntityDataSource;
33 if (entityDataSource != null && !String.IsNullOrEmpty(entityDataSource.ConnectionString))
35 List<EntityDataSourceContainerNameItem> containerNameItems = new EntityDataSourceDesignerHelper(entityDataSource, false /*interactiveMode*/).GetContainerNames(true /*sortResults*/);
36 string[] containers = new string[containerNameItems.Count];
37 for (int i = 0; i < containerNameItems.Count; i++)
39 containers[i] = containerNameItems[i].ToString();
41 return new StandardValuesCollection(containers);
47 public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
52 public override bool GetStandardValuesSupported(ITypeDescriptorContext context)