public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { string[] array = null; if (context != null) { IComponent instance = context.Instance as IComponent; if (instance != null) { ISite site = instance.Site; if (site != null) { IDesignerHost service = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (service != null) { IDesigner dataBoundControlDesigner = service.GetDesigner(instance); DesignerDataSourceView view = this.GetView(dataBoundControlDesigner); if (view != null) { IDataSourceDesigner dataSourceDesigner = view.DataSourceDesigner; if (dataSourceDesigner != null) { string[] viewNames = dataSourceDesigner.GetViewNames(); if (viewNames != null) { array = new string[viewNames.Length]; viewNames.CopyTo(array, 0); } } } if (((array == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider)) { IDataSourceProvider provider = dataBoundControlDesigner as IDataSourceProvider; object dataSource = null; if (provider != null) { dataSource = provider.GetSelectedDataSource(); } if (dataSource != null) { array = DesignTimeData.GetDataMembers(dataSource); } } } } } if (array == null) { array = new string[0]; } Array.Sort(array, Comparer.Default); } return(new TypeConverter.StandardValuesCollection(array)); }
public override DesignerDataSourceView GetView(string viewName) { if (string.IsNullOrEmpty(viewName)) viewName = "DefaultView"; if (viewName != "DefaultView") return null; if (_view == null) _view = new ObjectDesignerDataSourceView(this, viewName); return _view; }
public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) { object[] values = null; if (context != null) { IComponent instance = context.Instance as IComponent; if (instance != null) { ISite site = instance.Site; if (site != null) { IDesignerHost host = (IDesignerHost)site.GetService(typeof(IDesignerHost)); if (host != null) { IDesigner dataBoundControlDesigner = host.GetDesigner(instance); DesignerDataSourceView view = this.GetView(dataBoundControlDesigner); if (view != null) { IDataSourceViewSchema schema = null; try { schema = view.Schema; } catch (Exception exception) { IComponentDesignerDebugService service = (IComponentDesignerDebugService)site.GetService(typeof(IComponentDesignerDebugService)); if (service != null) { service.Fail(System.Design.SR.GetString("DataSource_DebugService_FailedCall", new object[] { "DesignerDataSourceView.Schema", exception.Message })); } } if (schema != null) { IDataSourceFieldSchema[] fields = schema.GetFields(); if (fields != null) { values = new object[fields.Length]; for (int i = 0; i < fields.Length; i++) { values[i] = fields[i].Name; } } } } if (((values == null) && (dataBoundControlDesigner != null)) && (dataBoundControlDesigner is IDataSourceProvider)) { IDataSourceProvider provider = dataBoundControlDesigner as IDataSourceProvider; IEnumerable dataSource = null; if (provider != null) { dataSource = provider.GetResolvedSelectedDataSource(); } if (dataSource != null) { PropertyDescriptorCollection dataFields = DesignTimeData.GetDataFields(dataSource); if (dataFields != null) { ArrayList list = new ArrayList(); foreach (PropertyDescriptor descriptor in dataFields) { list.Add(descriptor.Name); } values = list.ToArray(); } } } } } } } return(new TypeConverter.StandardValuesCollection(values)); }
public override DesignerDataSourceView GetView(string viewName) { if (string.IsNullOrEmpty(viewName)) { viewName = "DefaultView"; } if (!string.Equals(viewName, "DefaultView", StringComparison.OrdinalIgnoreCase)) { return null; } if (this._view == null) { this._view = this.CreateView(viewName); } return this._view; }