Example #1
0
        public bool IsNull(PropertyAccessor propertyAccessor, ClientTransaction transaction)
        {
            ArgumentUtility.CheckNotNull("propertyAccessor", propertyAccessor);
            ArgumentUtility.CheckNotNull("transaction", transaction);

            if (propertyAccessor.PropertyData.RelationEndPointDefinition.IsVirtual)
            {
                return(GetValueWithoutTypeCheck(propertyAccessor, transaction) == null);
            }
            else // for nonvirtual end points check out the ObjectID, which is stored in the DataContainer; this allows IsNull to avoid loading the object
            {
                return(ValuePropertyAccessorStrategy.Instance.GetValueWithoutTypeCheck(propertyAccessor, transaction) == null);
            }
        }
Example #2
0
        public void SetValueWithoutTypeCheck(PropertyAccessor propertyAccessor, ClientTransaction transaction, object value)
        {
            ArgumentUtility.CheckNotNull("propertyAccessor", propertyAccessor);
            ArgumentUtility.CheckNotNull("transaction", transaction);
            var newCollection = ArgumentUtility.CheckNotNullAndType <DomainObjectCollection> ("value", value);

            DomainObjectCheckUtility.EnsureNotDeleted(propertyAccessor.DomainObject, transaction);

            RelationEndPointID id = CreateRelationEndPointID(propertyAccessor);
            var endPoint          = (ICollectionEndPoint)transaction.DataManager.GetRelationEndPointWithLazyLoad(id);

            if (newCollection.AssociatedEndPointID != null && newCollection.AssociatedEndPointID != endPoint.ID)
            {
                throw new ArgumentException("The given collection is already associated with an end point.", "value");
            }

            if (newCollection.RequiredItemType != endPoint.Collection.RequiredItemType &&
                !newCollection.IsReadOnly &&
                !endPoint.Collection.IsReadOnly)
            {
                throw new InvalidOperationException("The given collection has a different item type than the end point's current opposite collection.");
            }

            if (newCollection.GetType() != endPoint.Collection.GetType())
            {
                var message = string.Format(
                    "The given collection ('{0}') is not of the same type as the end point's current opposite collection ('{1}').",
                    newCollection.GetType(),
                    endPoint.Collection.GetType());
                throw new InvalidOperationException(message);
            }

            var command = endPoint.CreateSetCollectionCommand(newCollection);
            var bidirectionalModification = command.ExpandToAllRelatedObjects();

            bidirectionalModification.NotifyAndPerform();
        }
Example #3
0
 private DataContainer GetDataContainer(PropertyAccessor propertyAccessor, ClientTransaction transaction)
 {
     return(transaction.DataManager.GetDataContainerWithLazyLoad(propertyAccessor.DomainObject.ID, throwOnNotFound: true));
 }
Example #4
0
 public RelationEndPointID CreateRelationEndPointID(PropertyAccessor propertyAccessor)
 {
     ArgumentUtility.CheckNotNull("propertyAccessor", propertyAccessor);
     return(RelatedObjectPropertyAccessorStrategy.Instance.CreateRelationEndPointID(propertyAccessor));
 }
Example #5
0
 public RelationEndPointID CreateRelationEndPointID(PropertyAccessor propertyAccessor)
 {
     ArgumentUtility.CheckNotNull("propertyAccessor", propertyAccessor);
     return(RelationEndPointID.Create(propertyAccessor.DomainObject.ID, propertyAccessor.PropertyData.RelationEndPointDefinition));
 }