コード例 #1
0
 private void SetConstraintsFromBinding(Binding binding)
 {
     if (binding.BindingManagerBase != null)
     {
         if (!this.IsFormatModeAndBindingCompatible(this.ownerControl.FormatMode, binding))
         {
             throw new InvalidOperationException();
         }
         PropertyDescriptorCollection itemProperties     = binding.BindingManagerBase.GetItemProperties();
         PropertyDescriptor           propertyDescriptor = itemProperties.Find(binding.BindingMemberInfo.BindingField, true);
         if (propertyDescriptor != null)
         {
             FilterValuePropertyDescriptor filterValuePropertyDescriptor = propertyDescriptor as FilterValuePropertyDescriptor;
             Type propertyType;
             if (filterValuePropertyDescriptor != null)
             {
                 propertyType = filterValuePropertyDescriptor.ValuePropertyType;
             }
             else
             {
                 propertyType = propertyDescriptor.PropertyType;
             }
             object    obj       = (binding.DataSource is BindingSource) ? ((BindingSource)binding.DataSource).DataSource : binding.DataSource;
             DataTable dataTable = obj as DataTable;
             if (dataTable != null)
             {
                 DataObjectStore dataObjectStore = dataTable.ExtendedProperties["DataSourceStore"] as DataObjectStore;
                 if (dataObjectStore != null)
                 {
                     DataColumn    dataColumn    = dataTable.Columns[binding.BindingMemberInfo.BindingField];
                     ColumnProfile columnProfile = dataColumn.ExtendedProperties["ColumnProfile"] as ColumnProfile;
                     if (!string.IsNullOrEmpty(columnProfile.DataObjectName))
                     {
                         Type dataObjectType = dataObjectStore.GetDataObjectType(columnProfile.DataObjectName);
                         if (null != dataObjectType)
                         {
                             obj          = dataObjectType;
                             propertyType = dataObjectType.GetProperty(columnProfile.MappingProperty).PropertyType;
                         }
                     }
                 }
             }
             PropertyDefinitionConstraint[] propertyDefinitionConstraints = PropertyConstraintProvider.GetPropertyDefinitionConstraints(obj, binding.BindingMemberInfo.BindingField);
             this.SetConstraintsFromType(propertyType, propertyDefinitionConstraints);
         }
     }
 }
コード例 #2
0
 public virtual Reader CreateBulkReader(string dataObjectName, DataObjectStore store, DataTable table)
 {
     return(new BulkEditReaderTask(store.GetDataObjectType(dataObjectName), store.GetDataObjectCreator(dataObjectName), dataObjectName, table));
 }