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); }
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 void GetIdentifier_ReturnsIdentifier() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue", typeOneClass); Assert.That(path.Identifier, Is.EqualTo("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue")); }
public void GetIsDynamic_ReturnsFalse() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue", typeOneClass); Assert.That(path.IsDynamic, Is.False); }
public void GetProperties_ThrowsNotSupportedException() { IBusinessObjectPropertyPath path = DynamicBusinessObjectPropertyPath.Create("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue"); Assert.That( () => path.Properties, Throws.TypeOf <NotSupportedException>().With.Message.EqualTo("Properties collection cannot be retrieved for dynamic property paths.")); }
public Formatter(IBusinessObject obj, IBusinessObjectPropertyPath path) { ArgumentUtility.CheckNotNull("obj", obj); ArgumentUtility.CheckNotNull("path", path); _object = obj; _path = path; }
private IBusinessObjectBoundEditableWebControl CreateControlForPosition(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); var control = CreateBocReferenceValue(propertyPath); control.PreRender += HandlePositionPreRender; control.EnableSelectStatement = false; return(control); }
public static string GetString(this IBusinessObjectPropertyPath propertyPath, IBusinessObject obj, string format) { ArgumentUtility.CheckNotNull("format", format); var result = propertyPath.GetResult( obj, UnreachableValueBehavior.ReturnNullForUnreachableValue, ListValueBehavior.GetResultForFirstListEntry); return(result.GetString(format)); }
public virtual void SetUp() { _stringValueClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(TypeWithString)); _stringValuePropertyPath = BusinessObjectPropertyPath.CreateStatic(_stringValueClass, "FirstValue"); _stringValueColumn = new BocSimpleColumnDefinition(); _stringValueColumn.SetPropertyPath(_stringValuePropertyPath); _factory = EditableRowControlFactory.CreateEditableRowControlFactory(); }
public static object GetValue( this IBusinessObjectPropertyPath propertyPath, IBusinessObject obj, bool throwExceptionIfNotReachable, bool getFirstListEntry) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); var result = propertyPath.GetResult( obj, throwExceptionIfNotReachable ? UnreachableValueBehavior.FailForUnreachableValue : UnreachableValueBehavior.ReturnNullForUnreachableValue, getFirstListEntry ? ListValueBehavior.GetResultForFirstListEntry : ListValueBehavior.FailForListProperties); return(result.GetValue()); }
protected virtual bool IsAutoCompleteReferenceValueRequired(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); var lastProperty = propertyPath.Properties.Last(); bool isScalarReferenceProperty = !lastProperty.IsList && lastProperty is IBusinessObjectReferenceProperty; if (isScalarReferenceProperty) { return(true); } return(false); }
public void GetProperties_ThrowsNotSupportedException() { var provider = BindableObjectProvider.GetProviderForBindableObjectType(typeof(TypeOne)); var typeOneClass = provider.GetBindableObjectClass(typeof(TypeOne)); var expectedProperties = new[] { typeOneClass.GetPropertyDefinition("TypeTwoValue"), provider.GetBindableObjectClass(typeof(TypeTwo)).GetPropertyDefinition("TypeThreeValue"), provider.GetBindableObjectClass(typeof(TypeThree)).GetPropertyDefinition("TypeFourValue"), provider.GetBindableObjectClass(typeof(TypeFour)).GetPropertyDefinition("IntValue"), }; IBusinessObjectPropertyPath path = StaticBusinessObjectPropertyPath.Parse("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue", typeOneClass); Assert.That(() => path.Properties, Is.EqualTo(expectedProperties)); }
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 GetResult_ValidPropertyPath_EndsWithInt() { var root = TypeOne.Create(); IBusinessObjectPropertyPath path = DynamicBusinessObjectPropertyPath.Create("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue"); var result = path.GetResult( (IBusinessObject)root, BusinessObjectPropertyPath.UnreachableValueBehavior.FailForUnreachableValue, BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties); Assert.That(result, Is.InstanceOf <EvaluatedBusinessObjectPropertyPathResult>()); Assert.That(result.ResultObject, Is.SameAs(root.TypeTwoValue.TypeThreeValue.TypeFourValue)); Assert.That( result.ResultProperty, Is.SameAs(((IBusinessObject)root.TypeTwoValue.TypeThreeValue.TypeFourValue).BusinessObjectClass.GetPropertyDefinition("IntValue"))); }
public virtual void CreateControls(IBusinessObject value, BocColumnDefinition[] columns) { ArgumentUtility.CheckNotNull("value", value); ArgumentUtility.CheckNotNullOrItemsNull("columns", columns); if (_dataSourceFactory == null) { throw new InvalidOperationException( string.Format("BocList '{0}': DataSourceFactory has not been set prior to invoking CreateControls().", _editModeHost.ID)); } if (_controlFactory == null) { throw new InvalidOperationException( string.Format("BocList '{0}': ControlFactory has not been set prior to invoking CreateControls().", _editModeHost.ID)); } CreatePlaceHolders(columns); _dataSource = _dataSourceFactory.Create(value); _rowEditModeControls = new IBusinessObjectBoundEditableWebControl[columns.Length]; for (int idxColumns = 0; idxColumns < columns.Length; idxColumns++) { BocSimpleColumnDefinition simpleColumn = columns[idxColumns] as BocSimpleColumnDefinition; if (IsColumnEditable(simpleColumn)) { IBusinessObjectBoundEditableWebControl control = _controlFactory.Create(simpleColumn, idxColumns); if (control != null) { control.ID = idxColumns.ToString(); control.DataSource = _dataSource; IBusinessObjectPropertyPath propertyPath = simpleColumn.GetPropertyPath(); control.Property = propertyPath.Properties[0]; SetEditControl(idxColumns, control); _rowEditModeControls[idxColumns] = control; } } } _isRowEditModeValidatorsRestored = false; }
private IBusinessObjectBoundEditableWebControl CreateControlForGroup(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); var control = base.CreateFromPropertyPath(propertyPath); if (control is BocAutoCompleteReferenceValue) { var referenceValue = (BocAutoCompleteReferenceValue)control; referenceValue.TextBoxStyle.AutoPostBack = true; return(referenceValue); } else if (control is BocReferenceValue) { var referenceValue = (BocReferenceValue)control; referenceValue.DropDownListStyle.AutoPostBack = true; return(referenceValue); } else { throw new InvalidOperationException(string.Format("Control type '{0}' is not supported for property 'Group'", control.GetType())); } }
public static IComparer <BocListRow> CreateComparer([NotNull] this IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); return(new BusinessObjectPropertyPathBasedComparer(propertyPath)); }
protected virtual BocReferenceValue CreateBocReferenceValue(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); return(new BocReferenceValue()); }
public void GetIdentifier_ReturnsIdentifier() { IBusinessObjectPropertyPath path = DynamicBusinessObjectPropertyPath.Create("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue"); Assert.That(path.Identifier, Is.EqualTo("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue")); }
public void GetIsDynamic_ReturnsTrue() { IBusinessObjectPropertyPath path = DynamicBusinessObjectPropertyPath.Create("TypeTwoValue.TypeThreeValue.TypeFourValue.IntValue"); Assert.That(path.IsDynamic, Is.True); }
protected override IBusinessObjectBoundEditableWebControl CreateFromPropertyPath(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); if (propertyPath.Identifier == "Position") { return(CreateControlForPosition(propertyPath)); } else { return(base.CreateFromPropertyPath(propertyPath)); } }
/// <summary> /// Sets the <see cref="IBusinessObjectPropertyPath"/> mananged by this <see cref="PropertyPathBinding"/>. /// </summary> public void SetPropertyPath(IBusinessObjectPropertyPath propertyPath) { _propertyPath = propertyPath; _propertyPathIdentifier = (propertyPath == null) ? string.Empty : propertyPath.Identifier; _isDynamic = (propertyPath == null) ? false : propertyPath.IsDynamic; }
/// <summary> /// Initializes a new instance of the <see cref="PropertyPathBinding"/> class with the /// <see cref="IBusinessObjectPropertyPath"/> managed by this instance. /// </summary> /// <param name="propertyPath"> /// The <see cref="IBusinessObjectPropertyPath"/> mananged by this /// <see cref="PropertyPathBinding"/>. /// </param> public PropertyPathBinding(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); SetPropertyPath(propertyPath); }
public void SetPropertyPath(IBusinessObjectPropertyPath propertyPath) { _propertyPathBinding.SetPropertyPath(propertyPath); }
private bool Is <T> (IBusinessObjectPropertyPath propertyPath) where T : OrganizationalStructureObject { return(typeof(T).IsAssignableFrom(propertyPath.Properties.Last().PropertyType)); }
protected override IBusinessObjectBoundEditableWebControl CreateFromPropertyPath(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); if (IsAutoCompleteReferenceValueRequired(propertyPath)) { return(CreateBocAutoCompleteReferenceValue(propertyPath)); } return(base.CreateFromPropertyPath(propertyPath)); }
protected virtual IBusinessObjectBoundEditableWebControl CreateBocAutoCompleteReferenceValue(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); var control = new BocAutoCompleteReferenceValue(); SecurityManagerSearchWebService.BindServiceToControl(control); if (Is <User> (propertyPath) || Is <Group> (propertyPath)) { control.PreRender += delegate { BasePage page = (BasePage)control.Page; control.Args = page.CurrentFunction.TenantHandle.AsArgument(); }; } return(control); }
protected virtual IBusinessObjectBoundEditableWebControl CreateFromPropertyPath(IBusinessObjectPropertyPath propertyPath) { ArgumentUtility.CheckNotNull("propertyPath", propertyPath); return((IBusinessObjectBoundEditableWebControl)ControlFactory.CreateControl(propertyPath.Properties.Last(), ControlFactory.EditMode.InlineEdit)); }
public static void SetValue(this IBusinessObjectPropertyPath propertyPath, IBusinessObject obj, object value) { throw new NotImplementedException(); }
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; }