public IBusinessObjectPropertyPath GetPropertyPath() { if (_propertyPath != null) { return(_propertyPath); } if (string.IsNullOrEmpty(_propertyPathIdentifier)) { _propertyPath = new NullBusinessObjectPropertyPath(); } else if (_isDynamic) { _propertyPath = BusinessObjectPropertyPath.CreateDynamic(_propertyPathIdentifier); } else { if (BusinessObjectClass == null) { if (!Remotion.Web.Utilities.ControlHelper.IsDesignMode(OwnerControl)) { throw new InvalidOperationException("The property path could not be resolved because the Business Object Class is not set."); } return(new NullBusinessObjectPropertyPath()); } else { _propertyPath = BusinessObjectPropertyPath.CreateStatic(BusinessObjectClass, _propertyPathIdentifier); } } return(_propertyPath); }
public override void SetUp() { base.SetUp(); _values = new IBusinessObject[5]; _values[0] = (IBusinessObject)TypeWithString.Create("0", "A"); _values[1] = (IBusinessObject)TypeWithString.Create("1", "A"); _values[2] = (IBusinessObject)TypeWithString.Create("2", "B"); _values[3] = (IBusinessObject)TypeWithString.Create("3", "B"); _values[4] = (IBusinessObject)TypeWithString.Create("4", "C"); _newValues = new IBusinessObject[2]; _newValues[0] = (IBusinessObject)TypeWithString.Create("5", "C"); _newValues[1] = (IBusinessObject)TypeWithString.Create("6", "D"); _typeWithStringClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithString)); _typeWithStringFirstValuePath = BusinessObjectPropertyPath.CreateStatic(_typeWithStringClass, "FirstValue"); _typeWithStringSecondValuePath = BusinessObjectPropertyPath.CreateStatic(_typeWithStringClass, "SecondValue"); _typeWithStringFirstValueSimpleColumn = new BocSimpleColumnDefinition(); _typeWithStringFirstValueSimpleColumn.SetPropertyPath(_typeWithStringFirstValuePath); _typeWithStringSecondValueSimpleColumn = new BocSimpleColumnDefinition(); _typeWithStringSecondValueSimpleColumn.SetPropertyPath(_typeWithStringSecondValuePath); _bocList = new BocListMock(); _bocList.ID = "BocList"; NamingContainer.Controls.Add(_bocList); _bocList.LoadUnboundValue(_values, false); _bocList.SwitchListIntoEditMode(); Assert.That(_bocList.IsListEditModeActive, Is.True); }
private string GetPropertyDisplayName(string propertyPathIdentifier) { IBusinessObject businessObject = _accessControlEntry; var propertyPath = BusinessObjectPropertyPath.CreateStatic(businessObject.BusinessObjectClass, propertyPathIdentifier); Assertion.IsTrue(propertyPath.Properties.Count >= 2); return(propertyPath.Properties[propertyPath.Properties.Count - 2].DisplayName); }
public virtual void SetUp() { _stringValueClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithString)); _stringValuePropertyPath = BusinessObjectPropertyPath.CreateStatic(_stringValueClass, "FirstValue"); _stringValueColumn = new BocSimpleColumnDefinition(); _stringValueColumn.SetPropertyPath(_stringValuePropertyPath); _factory = EditableRowControlFactory.CreateEditableRowControlFactory(); }
private void RenderPropertyPathString(HtmlTextWriter writer, string propertyPathIdentifier) { IBusinessObject businessObject = _accessControlEntry; var propertyPath = BusinessObjectPropertyPath.CreateStatic(businessObject.BusinessObjectClass, propertyPathIdentifier); var result = propertyPath.GetResult( businessObject, BusinessObjectPropertyPath.UnreachableValueBehavior.ReturnNullForUnreachableValue, BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties); writer.WriteEncodedText(result.GetString(null)); }
public override void SetUp() { base.SetUp(); _editModeHost = new FakeEditModeHost(); _editModeHost.ID = "BocList"; _editModeHost.RowIDProvider = new FakeRowIDProvider(); _editModeHost.EditModeControlFactory = EditableRowControlFactory.CreateEditableRowControlFactory(); _editModeHost.EditModeDataSourceFactory = new EditableRowDataSourceFactory(); _editableRow = new EditableRow(_editModeHost); _editableRow.ID = "Row"; NamingContainer.Controls.Add(_editableRow); _value01 = (IBusinessObject)TypeWithAllDataTypes.Create("A", 1); _typeWithAllDataTypesClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes)); _typeWithAllDataTypesStringValuePath = BusinessObjectPropertyPath.CreateStatic(_typeWithAllDataTypesClass, "String"); _typeWithAllDataTypesInt32ValuePath = BusinessObjectPropertyPath.CreateStatic(_typeWithAllDataTypesClass, "Int32"); _typeWithAllDataTypesStringValueSimpleColumn = new BocSimpleColumnDefinition(); _typeWithAllDataTypesStringValueSimpleColumn.SetPropertyPath(_typeWithAllDataTypesStringValuePath); _typeWithAllDataTypesStringValueSimpleColumnAsDynamic = new BocSimpleColumnDefinition(); _typeWithAllDataTypesStringValueSimpleColumnAsDynamic.SetPropertyPath(BusinessObjectPropertyPath.CreateDynamic("StringValue")); _typeWithAllDataTypesStringValueSimpleColumnAsDynamic.IsDynamic = true; _typeWithAllDataTypesInt32ValueSimpleColumn = new BocSimpleColumnDefinition(); _typeWithAllDataTypesInt32ValueSimpleColumn.SetPropertyPath(_typeWithAllDataTypesInt32ValuePath); _typeWithAllDataTypesStringValueFirstValueCompoundColumn = new BocCompoundColumnDefinition(); _typeWithAllDataTypesStringValueFirstValueCompoundColumn.PropertyPathBindings.Add( new PropertyPathBinding(_typeWithAllDataTypesStringValuePath)); _typeWithAllDataTypesStringValueFirstValueCompoundColumn.PropertyPathBindings.Add( new PropertyPathBinding(_typeWithAllDataTypesStringValuePath)); _typeWithAllDataTypesStringValueFirstValueCompoundColumn.FormatString = "{0}, {1}"; _typeWithAllDataTypesStringValueCustomColumn = new BocCustomColumnDefinition(); _typeWithAllDataTypesStringValueCustomColumn.SetPropertyPath(_typeWithAllDataTypesStringValuePath); _typeWithAllDataTypesStringValueCustomColumn.IsSortable = true; _commandColumn = new BocCommandColumnDefinition(); _rowEditModeColumn = new BocRowEditModeColumnDefinition(); _dropDownMenuColumn = new BocDropDownMenuColumnDefinition(); }
public void Compare_List() { var valueAA = TypeWithString.Create(); valueAA.StringArray = new[] { "A", "A" }; var valueBA = TypeWithString.Create(); valueBA.StringArray = new[] { "B", "A" }; var valueAB = TypeWithString.Create(); valueAB.StringArray = new[] { "A", "B" }; var valueNull = TypeWithString.Create(); valueNull.StringArray = null; var valueEmpty = TypeWithString.Create(); valueEmpty.StringArray = new string[0]; var bindableObjectClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithString)); var propertyPath = BusinessObjectPropertyPath.CreateStatic(bindableObjectClass, "StringArray"); var comparer = new BusinessObjectPropertyPathBasedComparer(propertyPath); CompareEqualValues(comparer, (IBusinessObject)valueAA, (IBusinessObject)valueAA); CompareEqualValues(comparer, (IBusinessObject)valueAA, (IBusinessObject)valueAB); CompareEqualValues(comparer, (IBusinessObject)valueNull, (IBusinessObject)valueNull); CompareEqualValues(comparer, (IBusinessObject)valueEmpty, (IBusinessObject)valueEmpty); CompareAscendingValues(comparer, (IBusinessObject)valueAA, (IBusinessObject)valueBA); CompareAscendingValues(comparer, (IBusinessObject)valueNull, (IBusinessObject)valueAA); CompareAscendingValues(comparer, (IBusinessObject)valueEmpty, (IBusinessObject)valueAA); CompareAscendingValues(comparer, (IBusinessObject)valueNull, (IBusinessObject)valueEmpty); CompareDescendingValues(comparer, (IBusinessObject)valueBA, (IBusinessObject)valueAA); CompareDescendingValues(comparer, (IBusinessObject)valueAA, (IBusinessObject)valueNull); CompareDescendingValues(comparer, (IBusinessObject)valueAA, (IBusinessObject)valueEmpty); CompareDescendingValues(comparer, (IBusinessObject)valueEmpty, (IBusinessObject)valueNull); }
public void Compare_ReferenceValues() { var valueA = TypeWithReference.Create(); valueA.ReferenceValue = TypeWithReference.Create("A"); var valueB = TypeWithReference.Create(); valueB.ReferenceValue = TypeWithReference.Create("B"); var valueNull = TypeWithReference.Create(); valueNull.ReferenceValue = null; var bindableObjectClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithReference)); var propertyPath = BusinessObjectPropertyPath.CreateStatic(bindableObjectClass, "ReferenceValue"); var comparer = new BusinessObjectPropertyPathBasedComparer(propertyPath); AssertCompare(comparer, valueA, valueB, valueNull); }
public void Compare_StringValues() { var valueA = TypeWithAllDataTypes.Create(); valueA.String = "A"; var valueB = TypeWithAllDataTypes.Create(); valueB.String = "B"; var valueNull = TypeWithAllDataTypes.Create(); valueNull.String = null; var bindableObjectClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes)); var propertyPath = BusinessObjectPropertyPath.CreateStatic(bindableObjectClass, "String"); var comparer = new BusinessObjectPropertyPathBasedComparer(propertyPath); AssertCompare(comparer, valueA, valueB, valueNull); }
private void InitializeListFieldViews() { IBusinessObjectProperty endDate = ListField.Property.ReferenceClass.GetPropertyDefinition("EndDate"); BocSimpleColumnDefinition endDateColumnDefinition = new BocSimpleColumnDefinition(); endDateColumnDefinition.ColumnTitle = "EndDate"; endDateColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new[] { endDate })); BocListView emptyView = new BocListView(); emptyView.Title = "Empty"; emptyView.ColumnDefinitions.AddRange(new BocColumnDefinition[] {}); BocListView datesView = new BocListView(); datesView.Title = "Dates"; datesView.ColumnDefinitions.AddRange(new BocColumnDefinition[] { endDateColumnDefinition }); ListField.AvailableViews.AddRange(new BocListView[] { emptyView, datesView }); }
override protected void OnLoad(EventArgs e) { base.OnLoad(e); IBusinessObjectProperty dateOfBirth = CurrentObject.BusinessObjectClass.GetPropertyDefinition("DateOfBirth"); IBusinessObjectProperty dateOfDeath = CurrentObject.BusinessObjectClass.GetPropertyDefinition("DateOfDeath"); IBusinessObjectProperty height = CurrentObject.BusinessObjectClass.GetPropertyDefinition("Height"); IBusinessObjectProperty gender = CurrentObject.BusinessObjectClass.GetPropertyDefinition("Gender"); IBusinessObjectProperty cv = CurrentObject.BusinessObjectClass.GetPropertyDefinition("CV"); IBusinessObjectProperty income = CurrentObject.BusinessObjectClass.GetPropertyDefinition("Income"); // Additional columns, in-code generated BocSimpleColumnDefinition birthdayColumnDefinition = new BocSimpleColumnDefinition(); birthdayColumnDefinition.ColumnTitle = "Birthday"; birthdayColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { dateOfBirth })); BocSimpleColumnDefinition dayofDeathColumnDefinition = new BocSimpleColumnDefinition(); dayofDeathColumnDefinition.ColumnTitle = "Day of Death"; dayofDeathColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { dateOfDeath })); dayofDeathColumnDefinition.Width = Unit.Parse("9.1em", CultureInfo.InvariantCulture); dayofDeathColumnDefinition.EnforceWidth = true; BocSimpleColumnDefinition heightColumnDefinition = new BocSimpleColumnDefinition(); heightColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { height })); BocSimpleColumnDefinition genderColumnDefinition = new BocSimpleColumnDefinition(); genderColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { gender })); BocSimpleColumnDefinition cvColumnDefinition = new BocSimpleColumnDefinition(); cvColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { cv })); BocSimpleColumnDefinition incomeColumnDefinition = new BocSimpleColumnDefinition(); incomeColumnDefinition.SetPropertyPath(BusinessObjectPropertyPath.CreateStatic(new [] { income })); BocListView datesView = new BocListView(); datesView.Title = "Dates"; datesView.ColumnDefinitions.AddRange( new BocColumnDefinition[] { birthdayColumnDefinition, dayofDeathColumnDefinition }); BocListView statsView = new BocListView(); statsView.Title = "Stats"; statsView.ColumnDefinitions.AddRange( new BocColumnDefinition[] { heightColumnDefinition, genderColumnDefinition }); BocListView cvView = new BocListView(); cvView.Title = "CV"; cvView.ColumnDefinitions.AddRange( new BocColumnDefinition[] { cvColumnDefinition }); BocListView incomeView = new BocListView(); incomeView.Title = "Income"; incomeView.ColumnDefinitions.AddRange( new BocColumnDefinition[] { incomeColumnDefinition }); ChildrenList.AvailableViews.AddRange(new BocListView[] { datesView, statsView, cvView, incomeView }); if (!IsPostBack) { ChildrenList.SelectedView = datesView; } if (!IsPostBack) { // ChildrenList.SetSortingOrder ( // new BocListSortingOrderEntry[] { // new BocListSortingOrderEntry ((BocColumnDefinition) ChildrenList.FixedColumns[7], SortingDirection.Ascending) }); } if (!IsPostBack) { ChildrenList.SwitchListIntoEditMode(); } if (!IsPostBack) { NumberOfNewRowsField.Value = 1; } NumberOfNewRowsField.IsDirty = false; }
override protected void OnLoad (EventArgs e) { base.OnLoad (e); IBusinessObjectProperty dateOfBirth = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("DateOfBirth"); IBusinessObjectProperty dateOfDeath = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("DateOfDeath"); IBusinessObjectProperty height = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("Height"); IBusinessObjectProperty gender = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("Gender"); IBusinessObjectProperty cv = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("CV"); IBusinessObjectProperty income = CurrentObject.BusinessObjectClass.GetPropertyDefinition ("Income"); // Additional columns, in-code generated BocSimpleColumnDefinition birthdayColumnDefinition = new BocSimpleColumnDefinition(); birthdayColumnDefinition.ColumnTitle = "Birthday"; birthdayColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{dateOfBirth})); birthdayColumnDefinition.Width = Unit.Parse ("14em"); birthdayColumnDefinition.EnforceWidth = true; BocSimpleColumnDefinition dayofDeathColumnDefinition = new BocSimpleColumnDefinition(); dayofDeathColumnDefinition.ColumnTitle = "Day of Death"; dayofDeathColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{dateOfDeath})); dayofDeathColumnDefinition.Width = Unit.Parse ("7em"); dayofDeathColumnDefinition.EnforceWidth = true; BocSimpleColumnDefinition heightColumnDefinition = new BocSimpleColumnDefinition(); heightColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{height})); BocSimpleColumnDefinition genderColumnDefinition = new BocSimpleColumnDefinition(); genderColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{gender})); BocSimpleColumnDefinition cvColumnDefinition = new BocSimpleColumnDefinition(); cvColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{cv})); cvColumnDefinition.FormatString = "lines=3"; BocSimpleColumnDefinition incomeColumnDefinition = new BocSimpleColumnDefinition(); incomeColumnDefinition.SetPropertyPath (BusinessObjectPropertyPath.CreateStatic (new []{income})); BocListView datesView = new BocListView(); datesView.Title = "Dates"; datesView.ColumnDefinitions.AddRange (new BocColumnDefinition[] {birthdayColumnDefinition, dayofDeathColumnDefinition}); BocListView statsView = new BocListView(); statsView.Title = "Stats"; statsView.ColumnDefinitions.AddRange (new BocColumnDefinition[] {heightColumnDefinition, genderColumnDefinition}); BocListView cvView = new BocListView(); cvView.Title = "CV"; cvView.ColumnDefinitions.AddRange (new BocColumnDefinition[] {cvColumnDefinition}); BocListView incomeView = new BocListView(); incomeView.Title = "Income"; incomeView.ColumnDefinitions.AddRange (new BocColumnDefinition[] {incomeColumnDefinition}); ChildrenList.AvailableViews.AddRange (new BocListView[] { datesView, statsView, cvView, incomeView}); if (! IsPostBack) ChildrenList.SelectedView = datesView; if (!IsPostBack) { ChildrenList.SetSortingOrder ( new BocListSortingOrderEntry[] { new BocListSortingOrderEntry ((IBocSortableColumnDefinition) ChildrenList.FixedColumns[7], SortingDirection.Ascending) }); } if (IsPostBack) { // BocListSortingOrderEntry[] sortingOrder = ChildrenList.GetSortingOrder(); } if (!IsPostBack) { JobList.SetSelectedRows (new[] { 1 }); ChildrenList.SetSelectedBusinessObjects (new[] { ChildrenList.Value[1] }); } }
public override void SetUp() { base.SetUp(); _actualEvents = new StringCollection(); _values = new IBusinessObject[5]; _values[0] = (IBusinessObject)TypeWithAllDataTypes.Create("A", 1); _values[1] = (IBusinessObject)TypeWithAllDataTypes.Create("B", 2); _values[2] = (IBusinessObject)TypeWithAllDataTypes.Create("C", 3); _values[3] = (IBusinessObject)TypeWithAllDataTypes.Create("D", 4); _values[4] = (IBusinessObject)TypeWithAllDataTypes.Create("E", 5); _newValues = new IBusinessObject[2]; _newValues[0] = (IBusinessObject)TypeWithAllDataTypes.Create("F", 6); _newValues[1] = (IBusinessObject)TypeWithAllDataTypes.Create("G", 7); _class = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithAllDataTypes)); _stringValuePath = BusinessObjectPropertyPath.CreateStatic(_class, "String"); _int32ValuePath = BusinessObjectPropertyPath.CreateStatic(_class, "Int32"); _stringValueSimpleColumn = new BocSimpleColumnDefinition(); _stringValueSimpleColumn.SetPropertyPath(_stringValuePath); _int32ValueSimpleColumn = new BocSimpleColumnDefinition(); _int32ValueSimpleColumn.SetPropertyPath(_int32ValuePath); _columns = new BocColumnDefinition[2]; _columns[0] = _stringValueSimpleColumn; _columns[1] = _int32ValueSimpleColumn; _editModeHost = new FakeEditModeHost(); _editModeHost.ID = "BocList"; _controller = new EditModeController(_editModeHost); _controller.ID = "Controller"; NamingContainer.Controls.Add(_controller); _controllerInvoker = new ControlInvoker(_controller); _editModeHost.NotifyOnEditableRowChangesCanceled = (i, o) => _actualEvents.Add(FormatChangesCanceledEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesCanceling = (i, o) => _actualEvents.Add(FormatChangesCancelingEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesSaved = (i, o) => _actualEvents.Add(FormatChangesSavedEventMessage(i, o)); _editModeHost.NotifyOnEditableRowChangesSaving = (i, o) => _actualEvents.Add(FormatChangesSavingEventMessage(i, o)); _editModeHost.NotifyAddRows = objects => { var oldLength = _editModeHost.Value.Count; _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Concat(objects).ToArray(); return(((IBusinessObject[])_editModeHost.Value).Select((o, i) => new BocListRow(i, o)).Skip(oldLength).ToArray()); }; _editModeHost.NotifyRemoveRows = objects => { var removedRows = ((IBusinessObject[])_editModeHost.Value) .Select((o, i) => new BocListRow(i, o)) .Where(r => objects.Contains(r.BusinessObject)) .ToArray(); _editModeHost.Value = ((IBusinessObject[])_editModeHost.Value).Except(objects).ToArray(); return(removedRows); }; _editModeHost.NotifyEndRowEditModeCleanUp = i => _actualEvents.Add(FormatEndRowEditModeCleanUp(i)); _editModeHost.NotifyEndListEditModeCleanUp = () => _actualEvents.Add(FormatEndListEditModeCleanUp()); _editModeHost.NotifyValidateEditableRows = () => _actualEvents.Add(FormatValidateEditableRows()); _editModeHost.Value = _values; _editModeHost.RowIDProvider = new FakeRowIDProvider(); _editModeHost.EditModeControlFactory = EditableRowControlFactory.CreateEditableRowControlFactory(); _editModeHost.EditModeDataSourceFactory = new EditableRowDataSourceFactory(); _editModeHost.EnableEditModeValidator = true; _editModeHost.AreCustomCellsValid = true; }