/// <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;
      }
    }
 private static IList CreateList (CreateListMethod createListMethod, IList template, int size)
 {
   if (createListMethod != null)
     return createListMethod (size);
   else if (template is Array)
     return Array.CreateInstance (template.GetType().GetElementType(), size);
   else 
     throw new NotSupportedException ("Cannot create instance if argument 'createListMethod' is null and 'template' is not an array.");
 }