public override void Setup(CollectionSourceBase collectionSource, XafApplication application) { base.Setup(collectionSource, application); AutoLoad = false; IObjectSpace objectSpace = collectionSource.ObjectSpace; objectSpace.Reloaded += new EventHandler(this.ObjectSpace_Reloaded); ITypeInfo objectTypeInfo = collectionSource.ObjectTypeInfo; var customSetting = ObjectTypeInfo.FindAttribute <CategorySettingAttribute>(); Setting = customSetting; Type memberType = null; if (customSetting == null) { IMemberInfo info2 = objectTypeInfo.FindMember("Category"); if (info2 == null) { throw new InvalidOperationException(string.Format("The {0} type does not declare the public {1} property.", objectTypeInfo.FullName, "Category")); } memberType = info2.MemberType; } else { memberType = customSetting.CategoryType; CategoryPropertyName = Setting.PropertyName; } this.categoriesListViewId = application.FindListViewId(memberType); if (string.IsNullOrEmpty(this.categoriesListViewId)) { throw new InvalidOperationException(string.Format("Cannot find ListView for the Category property type {0} in the Application Model. Make sure the property is of the business object type registered in the application.", memberType.FullName)); } if ((base.Model != null) && (this.categoriesListViewId == base.Model.Id)) { throw new InvalidOperationException(string.Format("The default category ListView ({0}) is the same as the container ListView. To avoid recursion, provide different EditorType settings for it.", this.categoriesListViewId)); } this.categoriesDataSource = application.CreateCollectionSource(objectSpace, memberType, this.categoriesListViewId); this.criteriaPropertyName = "Category." + objectSpace.GetKeyPropertyName(memberType); this.typeDescriptionProvider = new CategorizedListEditorTypeDescriptionProvider(objectTypeInfo.Type); this.typeDescriptionProvider.AddProvider(); }