понедельник, 8 февраля 2016 г.

SPList Items и GetItems

Продолжаем исследовать исходный код некоторых компонент SharePoint. В этот раз посмотрим различия между свойством SPList.Items и методом SPList.GetItems()
// Microsoft.SharePoint.SPList
public SPListItemCollection GetItems(params string[] fields)
{
 if (fields == null)
 {
  throw new System.ArgumentNullException("fields");
 }
 System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
 for (int i = 0; i < fields.Length; i++)
 {
  string text = fields[i];
  if (text != null)
  {
   stringBuilder.Append("");
  }
 }
 return this.GetItems(new SPQuery
 {
  ViewAttributes = "Scope=\"Recursive\"",
  ViewFields = stringBuilder.ToString()
 });
}

// Microsoft.SharePoint.SPList
/// Returns a collection of items from the list based on the specified query.
/// An  object that represents the items.
/// An  object that contains the query.
[ClientCallable]
public SPListItemCollection GetItems([ClientCallableConstraint(Type = ClientCallableConstraintType.NotNull)] SPQuery query)
{
 return new SPListItemCollection(this, query);
}

// Microsoft.SharePoint.SPList
/// Gets the number of items in the list.
/// A 32-bit integer that indicates the number of items.
[ClientCallable, ClientCallableConstraint(Type = ClientCallableConstraintType.Custom, FixedId = "a", Value = "It MUST be a greater than or equal to zero.")]
public int ItemCount
{
 get
 {
  this.EnsurePropsFresh();
  return (int)this.m_arrListProps[(int)((System.UIntPtr)20), (int)((System.UIntPtr)this.m_iRow)];
 }
}

0 коммент.:

Отправить комментарий