Пример #1
0
        /// <summary>
        /// Returns a collection of business objects that are connected to
        /// this object through the specified relationship (eg. would return
        /// a father and a mother if the relationship was "parents").  This
        /// method is to be used in the case of multiple relationships.
        /// </summary>
        /// <param name="relationshipName">The name of the relationship</param>
        /// <returns>Returns a business object collection</returns>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship specified is a single relationship, when a
        /// multiple one was expected</exception>
        public virtual IBusinessObjectCollection GetRelatedCollection(string relationshipName)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IMultipleRelationship multipleRelationship = GetMultiple(relationshipName);

            return(multipleRelationship.BusinessObjectCollection);
        }
Пример #2
0
        ///<summary>
        /// Returns a multiple relationship for with the specified relationship name.
        ///</summary>
        ///<param name="relationshipName">The specified relationship name</param>
        ///<returns>The multiple relationship</returns>
        public IMultipleRelationship GetMultiple(string relationshipName)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IMultipleRelationship relationship = GetRelationshipAsMultiple(relationshipName);

            return(relationship);
        }
Пример #3
0
        ///<summary>
        /// Returns a single relationship for with the specified relationship name.
        ///</summary>
        ///<param name="relationshipName">The specified relationship name</param>
        ///<returns>THe single relationship</returns>
        public ISingleRelationship GetSingle(string relationshipName)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IRelationship relationship = GetRelationshipAsSingle(relationshipName);

            return((ISingleRelationship)relationship);
        }
Пример #4
0
        /// <summary>
        /// Returns the business object that is related to this object
        /// through the specified relationship (eg. would return a father
        /// if the relationship was called "father").  This method is to be
        /// used in the case of single relationships.
        /// </summary>
        /// <param name="relationshipName">The name of the relationship</param>
        /// <returns>Returns a business object</returns>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship specified is a multiple relationship, when a
        /// single one was expected</exception>
        public T GetRelatedObject <T>(string relationshipName) where T : class, IBusinessObject, new()
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            SingleRelationship <T> relationship = GetSingle <T>(relationshipName);

            return(relationship.GetRelatedObject());
        }
Пример #5
0
        /// <summary>
        /// Returns the business object that is related to this object
        /// through the specified relationship (eg. would return a father
        /// if the relationship was called "father").  This method is to be
        /// used in the case of single relationships.
        /// </summary>
        /// <param name="relationshipName">The name of the relationship</param>
        /// <returns>Returns a business object</returns>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship specified is a multiple relationship, when a
        /// single one was expected</exception>
        public IBusinessObject GetRelatedObject(string relationshipName)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            ISingleRelationship relationship = GetSingle(relationshipName);

            return(relationship.GetRelatedObject());
        }
Пример #6
0
        ///<summary>
        /// Returns a strongly typed multiple relationship for with the specified relationship name.
        ///</summary>
        ///<param name="relationshipName">The specified relationship name</param>
        ///<returns>The multiple relationship</returns>
        public MultipleRelationship <T> GetMultiple <T>(string relationshipName)
            where T : BusinessObject, new()
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IMultipleRelationship relationship = GetRelationshipAsMultiple(relationshipName);

            return((MultipleRelationship <T>)relationship);
        }
Пример #7
0
        /// <summary>
        /// Returns a collection of business objects that are connected to
        /// this object through the specified relationship (eg. would return
        /// a father and a mother if the relationship was "parents").  This
        /// method is to be used in the case of multiple relationships.
        /// </summary>
        /// <param name="relationshipName">The name of the relationship</param>
        /// <returns>Returns a business object collection</returns>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship specified is a single relationship, when a
        /// multiple one was expected</exception>
        public BusinessObjectCollection <TBusinessObject> GetRelatedCollection <TBusinessObject>(string relationshipName)
            where TBusinessObject : BusinessObject, new()
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            MultipleRelationship <TBusinessObject> multipleRelationship = GetMultiple <TBusinessObject>(relationshipName);

            return(multipleRelationship.BusinessObjectCollection);
        }
Пример #8
0
        ///<summary>
        /// Returns a strongly typed single relationship for with the specified relationship name.
        ///</summary>
        ///<param name="relationshipName">The specified relationship name</param>
        ///<returns>THe single relationship</returns>
        public SingleRelationship <T> GetSingle <T>(string relationshipName)
            where T : class, IBusinessObject, new()
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IRelationship relationship = GetRelationshipAsSingle(relationshipName);

            return((SingleRelationship <T>)relationship);
        }
Пример #9
0
        private IMultipleRelationship GetRelationshipAsMultiple(string relationshipName)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IRelationship relationship = this[relationshipName];

            if (relationship is ISingleRelationship)
            {
                throw new InvalidRelationshipAccessException("The 'single' relationship " + relationshipName +
                                                             " was accessed as a 'multiple' relationship (using GetRelatedCollection()).");
            }
            return((IMultipleRelationship)relationship);
        }
Пример #10
0
        /// <summary>
        /// Sets the related business object of a <b>single</b> relationship.
        /// This includes setting the RelKey properties of the relationship owner
        /// to the value of the related object's properties.
        /// </summary>
        /// <param name="relationshipName">The name of a single relationship</param>
        /// <param name="relatedObject">The new related object</param>
        /// <exception cref="InvalidRelationshipAccessException">Thrown if
        /// the relationship named is a multiple relationship instead of a
        /// single one</exception>
        public void SetRelatedObject(string relationshipName, IBusinessObject relatedObject)
        {
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");
            IRelationship relationship = this[relationshipName];

            if (relationship is IMultipleRelationship)
            {
                throw new InvalidRelationshipAccessException("SetRelatedObject() was passed a relationship (" +
                                                             relationshipName +
                                                             ") that is of type 'multiple' when it expects a 'single' relationship");
            }
            ((ISingleRelationship)relationship).SetRelatedObject(relatedObject);
        }
Пример #11
0
        // ReSharper disable DoNotCallOverridableMethodsInConstructor
        private RelationshipDef(string relationshipName, Type relatedObjectClassType, string relatedObjectAssemblyName, string relatedObjectClassName, IRelKeyDef relKeyDef, bool keepReferenceToRelatedObject, DeleteParentAction deleteParentAction, InsertParentAction insertParentAction, RelationshipType relationshipType)
        {
            ArgumentValidationHelper.CheckArgumentNotNull(relKeyDef, "relKeyDef");
            ArgumentValidationHelper.CheckStringArgumentNotEmpty(relationshipName, "relationshipName");

            if (relatedObjectClassType != null)
            {
                MyRelatedObjectClassType = relatedObjectClassType;
            }
            else
            {
                _relatedObjectAssemblyName = relatedObjectAssemblyName;
                _relatedObjectClassName    = relatedObjectClassName;
                _relatedObjectClassType    = null;
            }
            RelKeyDef                    = relKeyDef;
            RelationshipName             = relationshipName;
            KeepReferenceToRelatedObject = keepReferenceToRelatedObject;
            this.DeleteParentAction      = deleteParentAction;
            this.InsertParentAction      = insertParentAction;
            RelationshipType             = relationshipType;
        }
Пример #12
0
 /// <summary>
 /// Returns true if a property with this name is part of this key
 /// </summary>
 /// <param name="propName">The property name</param>
 /// <returns>Returns true if it is contained</returns>
 public bool Contains(string propName)
 {
     ArgumentValidationHelper.CheckStringArgumentNotEmpty(propName, "propName");
     return(_props.ContainsKey(propName));
 }