AnantLabs / codesmith

Automatically exported from code.google.com/p/codesmith
1 stars 0 forks source link

Add Item Overloads to Child Collections #538

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
public ProjectResource GetItem(int resourceId)
{
  foreach (ProjectResource res in this)
    if (res.ResourceId == resourceId)
      return res;
  return null;
}

public void Assign(int resourceId)
{
  if (!(Contains(resourceId)))
  {
    ProjectResource resource = ProjectResource.NewProjectResource(resourceId);
    this.Add(resource);
  }
  else
  {
    throw new InvalidOperationException("Resource already assigned to project");
  }
}

public void Remove(int resourceId)
{
  foreach (ProjectResource res in this)
  {
    if (res.ResourceId == resourceId)
    {
      Remove(res);
      break;
    }
  }
}

public bool Contains(int resourceId)
{
  foreach (ProjectResource res in this)
    if (res.ResourceId == resourceId)
      return true;
  return false;
}

public bool ContainsDeleted(int resourceId)
{
  foreach (ProjectResource res in DeletedList)
    if (res.ResourceId == resourceId)
      return true;
  return false;
}

http://community.codesmithtools.com/Template_Frameworks/f/68/p/11619/44563.aspx#
44563

Original issue reported on code.google.com by bniemyjski on 19 Dec 2010 at 12:48

GoogleCodeExporter commented 9 years ago

Original comment by bniemyjski on 27 Dec 2010 at 2:17