/// <summary> /// Removes a EntityLink item to the collection. /// </summary> /// <param name="item">The item to remove.</param> public void Remove(EntityLink item) { if (item == null) { throw new ArgumentNullException("item"); } List.Remove(item); }
/// <summary> /// Constructor. /// </summary> public EntityLinkEventArgs(EntityLink entityLink) { if (entityLink == null) { throw new ArgumentNullException("entityLink"); } _entityLink = entityLink; }
/// <summary> /// Adds a EntityLink instance to the collection. /// </summary> /// <param name="item">The item to add.</param> public void Insert(int index, EntityLink item) { if (item == null) { throw new ArgumentNullException("item"); } List.Insert(index, item); }
/// <summary> /// Constructor. /// </summary> /// <param name="link"></param> public EntityLinkViewProperty(EntityLink link) : base(link.EntityType) { if (link == null) { throw new ArgumentNullException("link"); } _link = link; }
/// <summary> /// Adds a EntityLink instance to the collection. /// </summary> /// <param name="item">The item to add.</param> public int Add(EntityLink item) { if (item == null) { throw new ArgumentNullException("item"); } int index = List.Add(item); this.OnLinkAdded(new EntityLinkEventArgs(item)); return(index); }
/// <summary> /// Discovers if the given item is in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>Returns true if the given item is in the collection.</returns> public bool Contains(EntityLink item) { if (IndexOf(item) == -1) { return(false); } else { return(true); } }
/// <summary> /// Gets the parent for a given item. /// </summary> /// <param name="entity"></param> /// <param name="link"></param> /// <returns></returns> object IEntityPersistence.GetParent(object entity, string linkName, string[] parentFieldNames) { if (entity == null) { throw new ArgumentNullException("entity"); } if (linkName == null) { throw new ArgumentNullException("linkName"); } if (linkName.Length == 0) { throw new ArgumentOutOfRangeException("'linkName' is zero-length."); } if (parentFieldNames == null) { throw new ArgumentNullException("parentFieldNames"); } // get the link... if (EntityType == null) { throw new InvalidOperationException("EntityType is null."); } EntityLink link = this.EntityType.Links.GetLink(linkName, OnNotFound.ThrowException); if (link == null) { throw new InvalidOperationException("link is null."); } if (!(link is ChildToParentEntityLink)) { throw new InvalidOperationException(string.Format("Link '{0}' is a '{1}', not child-to-parent.", linkName, link.GetType())); } // get the field names... EntityField[] parentFields = this.EntityType.Fields.GetFields(parentFieldNames, OnNotFound.ThrowException); if (parentFields == null) { throw new ArgumentNullException("parentFields"); } if (parentFieldNames.Length != parentFields.Length) { throw new InvalidOperationException(string.Format("Length mismatch for 'parentFieldNames' and 'parentFields': {0} cf {1}.", parentFieldNames.Length, parentFields.Length)); } // defer... return(this.GetParent(entity, (ChildToParentEntityLink)link, parentFields)); }
/// <summary> /// Returns the index of the item in the collection. /// </summary> /// <param name="item">The item to find.</param> /// <returns>The index of the item, or -1 if it is not found.</returns> public int IndexOf(EntityLink item) { return(List.IndexOf(item)); }