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) }); }
/// <summary> /// Removes a range of values from a list and returns the resulting list. The original list may be modified. /// </summary> public static IList Remove (IList list, IList objects, IBusinessObjectReferenceProperty property, bool mustCreateCopy) { ArgumentUtility.CheckNotNull ("objects", objects); if (list == null) return null; if (list.IsFixedSize || (mustCreateCopy && ! (list is ICloneable))) { ArrayList arrayList = new ArrayList (list); foreach (object obj in objects) arrayList.Remove (obj); IList newList = CreateList (GetCreateListMethod (property), list, arrayList.Count); CopyTo (arrayList, newList); return newList; } else { if (mustCreateCopy) list = (IList) ((ICloneable) list).Clone(); foreach (object obj in objects) list.Remove (obj); return list; } }
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); }
protected override void Render(HtmlTextWriter writer) { if (IsDesignMode) { string type = "Unknown"; IBusinessObjectReferenceProperty property = Property as IBusinessObjectReferenceProperty; if (property != null && property.ReferenceClass != null) { type = property.ReferenceClass.Identifier; } writer.Write( "<table style=\"font-family: arial; font-size: x-small; BORDER-RIGHT: gray 1px solid; BORDER-TOP: white 1px solid; BORDER-LEFT: white 1px solid; BORDER-BOTTOM: gray 1px solid; BACKGROUND-COLOR: #d4d0c8\">" + "<tr><td colspan=\"2\"><b>User Control</b></td></tr>" + "<tr><td>Data Source:</td><td>{0}</td></tr>" + "<tr><td>Property:</td><td>{1}</td></tr>" + "<tr><td>Type:</td><td>{2}</td></tr>" + "<tr><td>User Control:</td><td>{3}</td></tr>", DataSourceControl, PropertyIdentifier, type, _userControlPath); } base.Render(writer); }
public override void SetUp() { base.SetUp(); _control = new BocAutoCompleteReferenceValueMock(); _control.ID = "BocAutoCompleteReferenceValue"; _control.Value = (IBusinessObjectWithIdentity)_businessObject; MockRepository mockRepository = new MockRepository(); _page = mockRepository.PartialMultiMock <Page> (typeof(ISmartPage)); ((ISmartPage)_page).Stub(stub => stub.Context).Return(new HttpContextWrapper(HttpContext.Current)); _page.Replay(); _page.Controls.Add(_control); _businessObject = TypeWithReference.Create(); _propertyReferenceValue = (IBusinessObjectReferenceProperty)((IBusinessObject)_businessObject).BusinessObjectClass.GetPropertyDefinition("ReferenceValue"); _dataSource = new StubDataSource(((IBusinessObject)_businessObject).BusinessObjectClass); _dataSource.BusinessObject = (IBusinessObject)_businessObject; ((IBusinessObject)_businessObject).BusinessObjectClass.BusinessObjectProvider.AddService <IGetObjectService> (new GetObjectService((IBusinessObjectWithIdentity)TypeWithReference.Create())); ((IBusinessObject)_businessObject).BusinessObjectClass.BusinessObjectProvider.AddService <IBusinessObjectWebUIService> (new ReflectionBusinessObjectWebUIService()); }
private IBusinessObject GetPropertyValue( IBusinessObject currentObject, IBusinessObjectReferenceProperty currentProperty, BusinessObjectPropertyPath.ListValueBehavior listValueBehavior, int propertyIndex) { if (currentProperty.IsList) { if (listValueBehavior == BusinessObjectPropertyPath.ListValueBehavior.FailForListProperties) { throw new InvalidOperationException( string.Format("Property #{0} of property path '{1}' is not a single-value property.", propertyIndex, Identifier)); } var list = (IList)currentObject.GetProperty(currentProperty); if (list.Count > 0) { return((IBusinessObject)list[0]); } else { return(null); } } else { return((IBusinessObject)currentObject.GetProperty(currentProperty)); } }
public bool SupportsProperty(IBusinessObjectReferenceProperty property) { ArgumentUtility.CheckNotNull("property", property); var domainObjectType = GetDomainObjectType(property); return(domainObjectType != null); }
public void UseBusinessObjectClassService_WithServiceReturningNull() { IBusinessObjectReferenceProperty property = CreateProperty("Scalar", typeof(ClassFromOtherBusinessObjectImplementation)); _bindableObjectProvider.AddService(typeof(IBusinessObjectClassService), new StubBusinessObjectClassService()); Dev.Null = property.ReferenceClass; }
/// <summary> /// Adds a range of objects to a list. The original list may be modified. /// </summary> public static IList AddRange (IList list, IList objects, IBusinessObjectReferenceProperty property, bool mustCreateCopy, bool createIfNull) { ArgumentUtility.CheckNotNull ("objects", objects); CreateListMethod createListMethod = GetCreateListMethod (property); if (list == null) { if (! createIfNull) throw new ArgumentNullException ("list"); list = CreateList (createListMethod, null, objects.Count); CopyTo (objects, list); return list; } if (list.IsFixedSize || (mustCreateCopy && ! (list is ICloneable))) { ArrayList arrayList = new ArrayList (list); arrayList.AddRange (objects); IList newList = CreateList (createListMethod, list, arrayList.Count); CopyTo (arrayList, newList); return newList; } else { if (mustCreateCopy) list = (IList) ((ICloneable) list).Clone(); foreach (object obj in objects) list.Add (obj); return list; } }
public void Delete(IBusinessObject referencingObject, IBusinessObjectReferenceProperty property, IBusinessObject value) { ArgumentUtility.CheckNotNull("property", property); ArgumentUtility.CheckNotNullAndType <ReferenceDataSourceTestDomainBase> ("value", value); // NOP }
public BusinessObjectPropertyTreeNodeInfo(IBusinessObjectReferenceProperty property) { ArgumentUtility.CheckNotNull("property", property); _text = property.DisplayName; _toolTip = string.Empty; _icon = null; _property = property; }
protected override IQueryable <IBusinessObject> CreateQuery( BaseSecurityManagerObject referencingObject, IBusinessObjectReferenceProperty property, TenantConstraint tenantConstraint, DisplayNameConstraint displayNameConstraint) { return(Tenant.FindAll().Apply(displayNameConstraint).Cast <IBusinessObject>()); }
public void SetUp() { _referencedDataSourceStub = MockRepository.GenerateStub <IBusinessObjectDataSource>(); _referencedDataSourceStub.BusinessObject = MockRepository.GenerateStub <IBusinessObject>(); _referencedDataSourceStub.Stub(_ => _.BusinessObjectClass).Return(MockRepository.GenerateStub <IBusinessObjectClass>()); _referencePropertyStub = MockRepository.GenerateStub <IBusinessObjectReferenceProperty> (); _referencePropertyStub.Stub(_ => _.ReflectedClass).Return(MockRepository.GenerateStub <IBusinessObjectClass>()); }
public BusinessObjectPropertyTreeNodeInfo(string text, string toolTip, IconInfo icon, IBusinessObjectReferenceProperty property) { ArgumentUtility.CheckNotNullOrEmpty("text", text); _text = text; _toolTip = toolTip; _icon = icon; _property = property; }
public override void SetUp() { base.SetUp(); _searchService = new GroupTypePropertyTypeSearchService(); IBusinessObjectClass groupClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Group)); _property = (IBusinessObjectReferenceProperty)groupClass.GetPropertyDefinition("GroupType"); Assert.That(_property, Is.Not.Null); }
public override void SetUp() { base.SetUp(); _searchService = new GroupPropertyTypeSearchService(); IBusinessObjectClass userClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(User)); _tenantProperty = (IBusinessObjectReferenceProperty)userClass.GetPropertyDefinition("Tenant"); Assert.That(_tenantProperty, Is.Not.Null); }
public override void SetUp() { base.SetUp(); _searchService = new SubstitutionPropertiesSearchService(); IBusinessObjectClass substitutionClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Substitution)); _otherProperty = (IBusinessObjectReferenceProperty)substitutionClass.GetPropertyDefinition("SubstitutedUser"); Assert.That(_otherProperty, Is.Not.Null); }
protected override IQueryable <IBusinessObject> CreateQuery( BaseSecurityManagerObject referencingObject, IBusinessObjectReferenceProperty property, TenantConstraint tenantConstraint, DisplayNameConstraint displayNameConstraint) { ArgumentUtility.CheckNotNull("tenantConstraint", tenantConstraint); return(Group.FindByTenant(tenantConstraint.Value).Apply(displayNameConstraint).Cast <IBusinessObject>()); }
public bool IsDefaultValue(IBusinessObject referencingObject, IBusinessObjectReferenceProperty property, IBusinessObject value, IBusinessObjectProperty[] emptyProperties) { ArgumentUtility.CheckNotNull("property", property); ArgumentUtility.CheckNotNullAndType <ReferenceDataSourceTestDomainBase> ("value", value); ArgumentUtility.CheckNotNull("emptyProperties", emptyProperties); // NOP return(true); }
private IQueryable <IBusinessObject> CreateQuery( QueryFactory queryFactory, TReferencingObject referencingSecurityManagerObject, IBusinessObjectReferenceProperty property, SecurityManagerSearchArguments searchArguments) { var query = queryFactory(referencingSecurityManagerObject, property, searchArguments.TenantConstraint, searchArguments.DisplayNameConstraint); return(query.Apply(searchArguments.ResultSizeConstraint)); }
protected override sealed QueryFactory GetQueryFactory(IBusinessObjectReferenceProperty property) { QueryFactory queryFactory; if (!_queryFactories.TryGetValue(property.Identifier, out queryFactory)) { throw new ArgumentException( string.Format("The property '{0}' is not supported by the '{1}' type.", property.Identifier, GetType().FullName)); } return(queryFactory); }
public void WithoutDefaultValueServiceAttribute_AndNoDefaultDefaultValueService_FromPropertyDeclaration() { IBusinessObjectReferenceProperty property = CreatePropertyWithoutMixing("NoDefaultValueService"); _mockRepository.ReplayAll(); bool actual = property.SupportsDefaultValue; _mockRepository.VerifyAll(); Assert.That(actual, Is.False); }
public override void SetUp() { base.SetUp(); _searchService = new RolePropertiesSearchService(); IBusinessObjectClass roleClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Role)); _positionProperty = (IBusinessObjectReferenceProperty)roleClass.GetPropertyDefinition("Position"); Assert.That(_positionProperty, Is.Not.Null); }
public IBusinessObject[] Search(IBusinessObject referencingObject, IBusinessObjectReferenceProperty property, ISearchAvailableObjectsArguments searchArguments) { var defaultSearchArguments = searchArguments as DefaultSearchArguments; if (defaultSearchArguments == null || string.IsNullOrEmpty(defaultSearchArguments.SearchStatement)) { return(_searchAllService.Search(referencingObject, property, searchArguments)); } else { return(_querySearchService.Search(referencingObject, property, searchArguments)); } }
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); }
public override void SetUp() { base.SetUp(); _testHelper = new OrganizationalStructureTestHelper(); _testHelper.Transaction.EnterNonDiscardingScope(); _searchService = new AbstractRoleDefinitionPropertyTypeSearchService(); IBusinessObjectClass aceClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(AccessControlEntry)); _property = (IBusinessObjectReferenceProperty)aceClass.GetPropertyDefinition("AccessControlList"); Assert.That(_property, Is.Not.Null); }
public override void SetUp() { base.SetUp(); _searchService = new SubstitutionPropertiesSearchService(); IBusinessObjectClass substitutionClass = BindableObjectProviderTestHelper.GetBindableObjectClass(typeof(Substitution)); _substitutedRoleProperty = (IBusinessObjectReferenceProperty)substitutionClass.GetPropertyDefinition("SubstitutedRole"); Assert.That(_substitutedRoleProperty, Is.Not.Null); _user = User.FindByUserName("group0/user1"); Assert.That(_user, Is.Not.Null); }
private IQueryable <IBusinessObject> FindPossibleSubstitutedRoles( Substitution substitution, IBusinessObjectReferenceProperty property, TenantConstraint tenantConstraint, DisplayNameConstraint displayNameConstraint) { ArgumentUtility.CheckNotNull("substitution", substitution); if (substitution.SubstitutedUser == null) { return(Enumerable.Empty <IBusinessObject>().AsQueryable()); } return(substitution.SubstitutedUser.Roles.Cast <IBusinessObject>().AsQueryable()); }
public void WithoutDefaultValueServiceAttribute_AndDefaultDefaultValueService_FromPropertyDeclaration() { var createObjectServiceMock = _mockRepository.StrictMock <IDefaultValueService> (); IBusinessObjectReferenceProperty property = CreatePropertyWithoutMixing("NoDefaultValueService"); Expect.Call(createObjectServiceMock.SupportsProperty(property)).Return(true); _mockRepository.ReplayAll(); _bindableObjectProviderForDeclaringType.AddService(createObjectServiceMock); bool actual = property.SupportsDefaultValue; _mockRepository.VerifyAll(); Assert.That(actual, Is.True); }
public void DefaultValueServiceFromPropertyType() { IDefaultValueServiceOnType serviceMock = _mockRepository.StrictMock <IDefaultValueServiceOnType> (); IBusinessObjectReferenceProperty property = CreateProperty("DefaultValueServiceFromPropertyType"); Expect.Call(serviceMock.SupportsProperty(property)).Return(true); _mockRepository.ReplayAll(); _bindableObjectProviderForPropertyType.AddService(serviceMock); bool actual = property.SupportsDefaultValue; _mockRepository.VerifyAll(); Assert.That(actual, Is.True); }