Пример #1
0
        /// <summary>
        /// Converts a value from a string to a DataSource.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <param name="culture">The culture.</param>
        /// <param name="value">The value.</param>
        /// <returns>A DataSource.</returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (!string.IsNullOrEmpty((string)value))
            {
                IDataSourcesProvider      provider    = (IDataSourcesProvider)context.Instance;
                BindingList <IDataSource> dataSources = provider.GetDataSources();
                Guid id = Guid.Parse(Regex.Match((string)value, CoreUtility.FieldMatchPattern).Groups[1].Value);
                return(dataSources.FirstOrDefault(dataSource => dataSource.ID == id));
            }

            return(null);
        }
Пример #2
0
        /// <summary>
        /// Gets a list of DataSource objects.
        /// </summary>
        /// <param name="context">The context.</param>
        /// <returns>The list of DataDestination items.</returns>
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context)
        {
            IDataSourcesProvider provider = (IDataSourcesProvider)context.Instance;

            return(new StandardValuesCollection(provider.GetDataSources()));
        }