public IconProxy GetIcon(string businessObjectClass, string businessObject, string arguments) { if (businessObjectClass == null) { return(null); } Type type = TypeUtility.GetType(businessObjectClass, true); var businessObjectProvider = BindableObjectProvider.GetProviderForBindableObjectType(type); var bindableObjectClass = businessObjectProvider.GetBindableObjectClass(type); IBusinessObjectWithIdentity businessObjectWithIdentity = null; if (!string.IsNullOrEmpty(businessObject)) { var businessObjectClassWithIdentity = (IBusinessObjectClassWithIdentity)bindableObjectClass; businessObjectWithIdentity = businessObjectClassWithIdentity.GetObject(businessObject); } var iconInfo = BusinessObjectBoundWebControl.GetIcon(businessObjectWithIdentity, bindableObjectClass.BusinessObjectProvider); if (iconInfo != null) { return(IconProxy.Create(new HttpContextWrapper(Context), iconInfo)); } return(null); }
public IBusinessObject[] Search(IBusinessObject referencingObject, IBusinessObjectReferenceProperty property, ISearchAvailableObjectsArguments searchArguments) { var defaultSearchArguments = searchArguments as DefaultSearchArguments; if (defaultSearchArguments == null || string.IsNullOrEmpty(defaultSearchArguments.SearchStatement)) { return(new IBusinessObject[0]); } QueryDefinition definition = DomainObjectsConfiguration.Current.Query.QueryDefinitions.GetMandatory(defaultSearchArguments.SearchStatement); if (definition.QueryType != QueryType.Collection) { throw new ArgumentException(string.Format("The query '{0}' is not a collection query.", defaultSearchArguments.SearchStatement)); } var referencingDomainObject = referencingObject as DomainObject; var clientTransaction = referencingDomainObject != null ? referencingDomainObject.DefaultTransactionContext.ClientTransaction : ClientTransaction.Current; if (clientTransaction == null) { throw new InvalidOperationException("No ClientTransaction has been associated with the current thread or the referencing object."); } var result = clientTransaction.QueryManager.GetCollection(QueryFactory.CreateQuery(definition)); var availableObjects = new IBusinessObjectWithIdentity[result.Count]; if (availableObjects.Length > 0) { result.ToArray().CopyTo(availableObjects, 0); } return(availableObjects); }
private void CreateRootTreeNodes() { if (Value != null) { for (int i = 0; i < Value.Count; i++) { IBusinessObjectWithIdentity businessObject = (IBusinessObjectWithIdentity)Value[i]; BusinessObjectTreeNode node = CreateBusinessObjectNode(null, businessObject); _treeView.Nodes.Add(node); if (EnableTopLevelExpander) { if (EnableLookAheadEvaluation) { node.Evaluate(); } else { node.IsEvaluated = false; } } else // Top-Level nodes are expanded { node.EvaluateExpand(); if (EnableLookAheadEvaluation) { node.EvaluateChildren(); } } } } }
/// <summary> /// Gets the <see cref="IBusinessObjectWithIdentity.DisplayName"/> property of <paramref name="businessObject"/> /// after checking that the property's value can be read. /// </summary> /// <remarks> /// Getting the <see cref="IBusinessObjectWithIdentity.DisplayName"/> can still fail with an exception if the exception is not part of the /// property access contract, i.e. the exception is not of type <see cref="BusinessObjectPropertyAccessException"/>. /// </remarks> public static string GetAccessibleDisplayName(this IBusinessObjectWithIdentity businessObject) { ArgumentUtility.CheckNotNull("businessObject", businessObject); var businessObjectClass = businessObject.BusinessObjectClass; Assertion.IsNotNull(businessObjectClass, "The business object's BusinessObjectClass-property evaluated and returned null."); var displayNameProperty = businessObjectClass.GetPropertyDefinition("DisplayName"); if (displayNameProperty == null) { // No property-is-accessible checks can be performed. // This code path would only be exercised if the DisplayName property is not included in the bound properties. return(businessObject.DisplayName); } if (displayNameProperty.IsAccessible(businessObject)) { try { return((string)businessObject.GetProperty(displayNameProperty)); } catch (BusinessObjectPropertyAccessException) { // Fallback to not-accessible-property behavior } } var businessObjectProvider = displayNameProperty.BusinessObjectProvider; Assertion.IsNotNull(businessObjectProvider, "IBusinessObjectProperty.BusinessObjectProvider cannot be null."); return(businessObjectProvider.GetNotAccessiblePropertyStringPlaceHolder()); }
protected bool RenderBeginTagDataCellCommand( BocColumnRenderingContext <TBocColumnDefinition> renderingContext, IBusinessObject businessObject, int originalRowIndex) { ArgumentUtility.CheckNotNull("renderingContext", renderingContext); ArgumentUtility.CheckNotNull("businessObject", businessObject); BocListItemCommand command = renderingContext.ColumnDefinition.Command; if (command == null) { return(false); } if (string.IsNullOrEmpty(command.ItemID)) { command.ItemID = "Column_" + renderingContext.ColumnIndex + "_Command"; } bool isReadOnly = renderingContext.Control.IsReadOnly; bool isActive = command.Show == CommandShow.Always || isReadOnly && command.Show == CommandShow.ReadOnly || !isReadOnly && command.Show == CommandShow.EditMode; bool isCommandAllowed = (command.Type != CommandType.None) && !renderingContext.Control.EditModeController.IsRowEditModeActive; bool isCommandEnabled = (command.CommandState == null) || command.CommandState.IsEnabled(renderingContext.Control, businessObject, renderingContext.ColumnDefinition); bool isCommandWaiCompliant = (!WcagHelper.Instance.IsWaiConformanceLevelARequired() || command.Type == CommandType.Href); if (isActive && isCommandAllowed && isCommandEnabled && isCommandWaiCompliant) { string objectID = null; IBusinessObjectWithIdentity businessObjectWithIdentity = businessObject as IBusinessObjectWithIdentity; if (businessObjectWithIdentity != null) { objectID = businessObjectWithIdentity.UniqueIdentifier; } string argument = renderingContext.Control.GetListItemCommandArgument(renderingContext.ColumnIndex, new BocListRow(originalRowIndex, businessObject)); string postBackEvent = renderingContext.Control.Page.ClientScript.GetPostBackEventReference(renderingContext.Control, argument) + ";"; string onClick = renderingContext.Control.HasClientScript ? c_onCommandClickScript : string.Empty; if (command.Type == CommandType.None) { renderingContext.Writer.AddAttribute(HtmlTextWriterAttribute.Class, CssClasses.Disabled); } var commandIDBackup = command.ItemID; try { command.ItemID = command.ItemID + "_Row_" + originalRowIndex; command.RenderBegin(renderingContext.Writer, LegacyRenderingFeatures.ForLegacy, postBackEvent, onClick, originalRowIndex, objectID, businessObject as ISecurableObject); } finally { command.ItemID = commandIDBackup; } return(true); } return(false); }
/// <summary> Loads the <see cref="BocReferenceValueBase.Value"/> from the bound <see cref="IBusinessObject"/>. </summary> /// <include file='..\..\doc\include\UI\Controls\BocReferenceValue.xml' path='BocReferenceValue/LoadValue/*' /> public override void LoadValue(bool interim) { if (interim) { return; } if (Property == null) { return; } if (DataSource == null) { return; } IBusinessObjectWithIdentity value = null; if (DataSource.BusinessObject != null) { value = (IBusinessObjectWithIdentity)DataSource.BusinessObject.GetProperty(Property); } LoadValueInternal(value, false); }
public BusinessObjectWithIdentityProxy(IBusinessObjectWithIdentity obj) { ArgumentUtility.CheckNotNull("obj", obj); _uniqueIdentifier = obj.UniqueIdentifier; _displayName = obj.GetAccessibleDisplayName(); }
public void HasValue_ValueIsSet_ReturnsTrue() { IBusinessObjectWithIdentity referencedObject = (IBusinessObjectWithIdentity)TypeWithReference.Create(); _control.Value = referencedObject; Assert.That(_control.HasValue, Is.True); }
protected virtual BusinessObjectPropertyTreeNodeInfo[] GetPropertyNodes( BusinessObjectTreeNode parentNode, IBusinessObjectWithIdentity parentBusinessObject) { ArgumentUtility.CheckNotNull("parentNode", parentNode); ArgumentUtility.CheckNotNull("parentBusinessObject", parentBusinessObject); if (Property == null) { ArrayList referenceListPropertyInfos = new ArrayList(); IBusinessObjectProperty[] properties = parentBusinessObject.BusinessObjectClass.GetPropertyDefinitions(); for (int i = 0; i < properties.Length; i++) { IBusinessObjectReferenceProperty referenceProperty = properties[i] as IBusinessObjectReferenceProperty; if (referenceProperty != null && referenceProperty.IsList && referenceProperty.ReferenceClass is IBusinessObjectClassWithIdentity && referenceProperty.IsAccessible(parentBusinessObject)) { referenceListPropertyInfos.Add(new BusinessObjectPropertyTreeNodeInfo(referenceProperty)); } } return((BusinessObjectPropertyTreeNodeInfo[])referenceListPropertyInfos.ToArray(typeof(BusinessObjectPropertyTreeNodeInfo))); } return(new[] { new BusinessObjectPropertyTreeNodeInfo(Property) }); }
protected override BusinessObjectPropertyTreeNodeInfo[] GetPropertyNodes( BusinessObjectTreeNode parentNode, IBusinessObjectWithIdentity businessObject) { BusinessObjectPropertyTreeNodeInfo[] nodeInfos; if (businessObject is Person) { nodeInfos = new BusinessObjectPropertyTreeNodeInfo[2]; nodeInfos[0] = new BusinessObjectPropertyTreeNodeInfo( "Children", "ToolTip: Children", new IconInfo(null, Unit.Empty, Unit.Empty), (IBusinessObjectReferenceProperty)businessObject.BusinessObjectClass.GetPropertyDefinition("Children")); nodeInfos[1] = new BusinessObjectPropertyTreeNodeInfo( "Jobs", "ToolTip: Jobs", new IconInfo(null, Unit.Empty, Unit.Empty), (IBusinessObjectReferenceProperty)businessObject.BusinessObjectClass.GetPropertyDefinition("Jobs")); } else { nodeInfos = new BusinessObjectPropertyTreeNodeInfo[0]; } return(nodeInfos); }
public void DisplayName_Overridden_ValueFromMixin() { BindableObjectWithIdentityMixin mixin = Mixin.Get <BindableObjectWithIdentityMixin> (ObjectFactory.Create <ClassWithIdentityAndDisplayName> (ParamList.Create("TheUniqueIdentifier"))); IBusinessObjectWithIdentity businessObjectWithIdentity = mixin; Assert.That(businessObjectWithIdentity.DisplayName, Is.SameAs("TheUniqueIdentifier")); }
public void GetUniqueIdentifier() { BindableObjectWithIdentityMixin mixin = Mixin.Get <BindableObjectWithIdentityMixin> (ObjectFactory.Create <ClassWithIdentity>(ParamList.Create("TheUniqueIdentifier"))); IBusinessObjectWithIdentity businessObjectWithIdentity = mixin; Assert.That(businessObjectWithIdentity.UniqueIdentifier, Is.SameAs("TheUniqueIdentifier")); }
public void GetAndSet_UniqueIdentifierFromBusinessObjectWithIdentity() { Tenant tenant = TestHelper.CreateTenant("TestTenant", string.Empty); IBusinessObjectWithIdentity businessObject = tenant; tenant.UniqueIdentifier = "My Unique Identifier"; Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(tenant.ID.ToString())); }
public void SetAndGet_UniqueIdentifierFromBusinessObjectWithIdentity() { Group group = CreateGroup(); IBusinessObjectWithIdentity businessObject = group; group.UniqueIdentifier = "My Unique Identifier"; Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(@group.ID.ToString())); }
public void SetProperty_UniqueIdentifier() { Tenant tenant = TestHelper.CreateTenant("TestTenant", string.Empty); IBusinessObjectWithIdentity businessObject = tenant; businessObject.SetProperty("UniqueIdentifier", "My Unique Identifier"); Assert.That(tenant.UniqueIdentifier, Is.EqualTo("My Unique Identifier")); Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(tenant.ID.ToString())); }
public void DisplayName_BaseImplementation() { var mixin = Mixin.Get <BindableObjectWithIdentityMixin> (ObjectFactory.Create <ClassWithIdentity>(ParamList.Empty)); IBusinessObjectWithIdentity businessObject = mixin; Assert.That( businessObject.DisplayName, Is.EqualTo("Remotion.ObjectBinding.UnitTests.TestDomain.ClassWithIdentity, Remotion.ObjectBinding.UnitTests")); }
public void SetValueToObject() { IBusinessObjectWithIdentity referencedObject = (IBusinessObjectWithIdentity)TypeWithReference.Create(); _control.IsDirty = false; _control.Value = referencedObject; Assert.That(_control.Value, Is.EqualTo(referencedObject)); Assert.That(_control.IsDirty, Is.True); }
public void SetProperty_UniqueIdentifier() { Group group = CreateGroup(); IBusinessObjectWithIdentity businessObject = group; businessObject.SetProperty("UniqueIdentifier", "My Unique Identifier"); Assert.That(@group.UniqueIdentifier, Is.EqualTo("My Unique Identifier")); Assert.That(businessObject.UniqueIdentifier, Is.EqualTo(@group.ID.ToString())); }
/// <summary> Performs the actual loading for <see cref="LoadValue"/> and <see cref="LoadUnboundValue"/>. </summary> protected virtual void LoadValueInternal(IBusinessObjectWithIdentity value, bool interim) { if (interim) { return; } SetValue(value); IsDirty = false; }
public void LoadUnboundValueAndInterimFalseWithNull() { const IBusinessObjectWithIdentity value = null; _control.Property = _propertyReferenceValue; _control.Value = (IBusinessObjectWithIdentity)TypeWithReference.Create(); _control.IsDirty = true; _control.LoadUnboundValue(value, false); Assert.That(_control.Value, Is.EqualTo(value)); Assert.That(_control.IsDirty, Is.False); }
public void GetPropertyDefinition_UniqueIdentifier() { Tenant tenant = TestHelper.CreateTenant("TestTenant", string.Empty); IBusinessObjectWithIdentity businessObject = tenant; tenant.UniqueIdentifier = "My Unique Identifier"; IBusinessObjectProperty property = businessObject.BusinessObjectClass.GetPropertyDefinition("UniqueIdentifier"); Assert.IsInstanceOf(typeof(IBusinessObjectStringProperty), property); Assert.That(businessObject.GetProperty(property), Is.EqualTo("My Unique Identifier")); }
public void LoadUnboundValueAndInterimTrue() { IBusinessObjectWithIdentity value = (IBusinessObjectWithIdentity)TypeWithReference.Create(); _bocReferenceValue.Property = _propertyReferenceValue; _bocReferenceValue.Value = null; _bocReferenceValue.IsDirty = true; _bocReferenceValue.LoadUnboundValue(value, true); Assert.That(_bocReferenceValue.Value, Is.EqualTo(null)); Assert.That(_bocReferenceValue.IsDirty, Is.True); }
public void GetPropertyDefinition_UniqueIdentifier() { Group group = CreateGroup(); IBusinessObjectWithIdentity businessObject = group; group.UniqueIdentifier = "My Unique Identifier"; IBusinessObjectProperty property = businessObject.BusinessObjectClass.GetPropertyDefinition("UniqueIdentifier"); Assert.IsInstanceOf(typeof(IBusinessObjectStringProperty), property); Assert.That(businessObject.GetProperty(property), Is.EqualTo("My Unique Identifier")); }
/// <summary> Fires the <see cref="CommandClick"/> event. </summary> /// <param name="businessObject"> /// The current <see cref="Value"/>, which corresponds to the clicked <see cref="IBusinessObjectWithIdentity"/>, /// unless somebody changed the <see cref="Value"/> in the code behind before the event fired. /// </param> protected virtual void OnCommandClick(IBusinessObjectWithIdentity businessObject) { if (Command != null) { Command.OnClick(businessObject); BocCommandClickEventHandler commandClickHandler = (BocCommandClickEventHandler)Events[CommandClickEvent]; if (commandClickHandler != null) { BocCommandClickEventArgs e = new BocCommandClickEventArgs(Command, businessObject); commandClickHandler(this, e); } } }
private BusinessObjectTreeNode CreateBusinessObjectNode( IBusinessObjectReferenceProperty property, IBusinessObjectWithIdentity businessObject) { string id = businessObject.UniqueIdentifier; string text = GetText(businessObject); string toolTip = GetToolTip(businessObject); IconInfo icon = GetIcon(businessObject, businessObject.BusinessObjectClass.BusinessObjectProvider); BusinessObjectTreeNode node = new BusinessObjectTreeNode(id, text, toolTip, icon, property, businessObject); node.IsEvaluated = false; return(node); }
private void CreateAndAppendBusinessObjectNodes( BocTreeNode parentNode, IBusinessObjectWithIdentity parentBusinessObject, IBusinessObjectReferenceProperty parentProperty) { var children = GetBusinessObjects(parentNode, parentBusinessObject, parentProperty); for (int i = 0; i < children.Length; i++) { IBusinessObjectWithIdentity childBusinessObject = children[i]; BusinessObjectTreeNode childNode = CreateBusinessObjectNode(parentProperty, childBusinessObject); parentNode.Children.Add(childNode); } }
protected override sealed void SetValue(IBusinessObjectWithIdentity value) { _value = value; if (value != null) { InternalValue = value.UniqueIdentifier; InternalDisplayName = GetDisplayName(value); } else { InternalValue = null; InternalDisplayName = null; } }
/// <summary> Loads the <see cref="Value"/> from the bound <see cref="IBusinessObject"/>. </summary> /// <include file='..\..\doc\include\UI\Controls\BocTreeView.xml' path='BocTreeView/LoadValue/*' /> public override void LoadValue(bool interim) { if (DataSource == null) { return; } IBusinessObjectWithIdentity value = null; if (DataSource.BusinessObject != null) { value = (IBusinessObjectWithIdentity)DataSource.BusinessObject; } LoadValueInternal(value, interim); }
protected override sealed IBusinessObjectWithIdentity GetValue() { if (InternalValue == null) { _value = null; } // Only reload if value is outdated else if (_value == null || _value.UniqueIdentifier != InternalValue) { var businessObjectClass = GetBusinessObjectClass(); if (businessObjectClass != null) { _value = businessObjectClass.GetObject(InternalValue); } } return(_value); }
protected override IBusinessObjectWithIdentity[] GetBusinessObjects( BocTreeNode parentNode, IBusinessObjectWithIdentity parent, IBusinessObjectReferenceProperty property) { if (parent.UniqueIdentifier == new Guid(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1).ToString()) { IList children = (IList)parent.GetProperty(property); ArrayList childrenList = new ArrayList(); for (int i = 0; i < children.Count; i++) { if (i != 1) { childrenList.Add(children[i]); } } return((IBusinessObjectWithIdentity[])childrenList.ToArray(typeof(IBusinessObjectWithIdentity))); } return(base.GetBusinessObjects(parentNode, parent, property)); }