DocumentCollection
Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.DocumentCollection
Represents a strongly typed list of documents that can be accessed by index.
If the DocumentCollection object does not indicate to the real html element of dom model when this property is true. Also objects of this class contains IsNull property for identification of document collection’s existence. Almost all classes of ZennoLab.CommandCenter contains such properties. Use it for the correct execution of the code.
Properties
IsVoid
Property
Gets the specified collection is void collection or not.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents
DocumentCollection docCol = tab.AllDocuments;
// if collection is void
if (docCol.IsVoid) return -1;
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents
$docCol = $tab->AllDocuments;
// if collection is void
if ($docCol->IsVoid) return -1;
return 0;
}ErrorDetected
Property
Gets information about the error detected in the performance last command
If the DocumentCollection object does not indicate to the real document collection then this property is true. Also objects of this class contains IsVoid property for identification of document collection’s existence. Almost all classes of ZennoLab.CommandCenter contains such properties. Use it for the correct execution of the code.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// add range to collection
docCol.AddRange(tab.AllDocuments);
// if any error
if (docCol.ErrorDetected) return -1;
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// add range to collection
$docCol->AddRange($tab->AllDocuments);
// if any error
if ($docCol->ErrorDetected) return -1;
return 0;
}Count
Property
Gets the number of elements actually contained in the DocumentCollection.
Count is the number of elements that are actually in the DocumentCollection.
Example
// get all documents from page
DocumentCollection docCol = tab.AllDocuments;
// get count
int count = docCol.Count;Example2
// get all documents from page
$docCol = $tab->AllDocuments;
// get count
$count = $docCol->Count;Documents
Property
Gets copies the documents of the DocumentCollection to a new array.
Example
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get an array of documents
Document[] docs = docCol.Documents;Example2
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get an array of documents
$docs = $docCol->Documents;Methods
GetByNumber
Method
Gets the document by specified number.
Parameters
| Параметр | Описание |
|---|---|
number | The zero-based number of the document to get. |
Returns: The document at the specified number.
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents
DocumentCollection docCol = tab.AllDocuments;
if (docCol.Count <= 0) return -1;
// get document by number
Document doc = docCol.GetByNumber(docCol.Count-1);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents
$docCol = $tab->AllDocuments;
if ($docCol->Count <= 0) return -1;
// get document by number
$doc = $docCol->GetByNumber($docCol->Count-1);
return 0;
}Add
Method
Adds a document to the end of the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
document | The document to be added to the end of the DocumentCollection. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from zennolab.com
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from lessons.zennolab.com
DocumentCollection newDocCol = tab.AllDocuments;
// add elements of second collection to first collection
for (int i = 0; i < newDocCol.Count; i++) docCol.Add(newDocCol.Documents[i]);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from zennolab.com
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from lessons.zennolab.com
$newDocCol = $tab->AllDocuments;
// add elements of second collection to first collection
for ($i = 0; $i < $newDocCol->Count; $i++) $docCol->Add($newDocCol->Documents[$i]);
return 0;
}AddRange
Method
Adds the documents of the specified collection to the end of the DocumentCollection.
The order of the elements in the collection is preserved in the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
documents | The collection whose documents should be added to the end of the DocumentCollection. The collection itself cannot be null. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from zennolab.com
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from lessons.zennolab.com
DocumentCollection newDocCol = tab.AllDocuments;
// add elements from second collection to first collection
docCol.AddRange(newDocCol);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from zennolab.com
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from lessons.zennolab.com
$newDocCol = $tab->AllDocuments;
// add elements from second collection to first collection
$docCol->AddRange($newDocCol);
return 0;
}AddRange
Method
Adds the documents of the specified array to the end of the DocumentCollection.
The order of the elements in the collection is preserved in the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
documents | The array whose documents should be added to the end of the DocumentCollection. The collection itself cannot be null. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from zennolab.com
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from lessons.zennolab.com
DocumentCollection newDocCol = tab.AllDocuments;
// add elements from second collection to first collection
docCol.AddRange(newDocCol.Documents);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from zennolab.com
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from lessons.zennolab.com
$newDocCol = $tab->AllDocuments;
// add elements from second collection to first collection
$docCol->AddRange($newDocCol->Documents);
return 0;
}Insert
Method
Inserts a document into the DocumentCollection at the specified index.
If index is equal to Count, item is added to the end of DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
document | The document to insert. |
index | The zero-based index at which document should be inserted. |
Example
// get all documents
DocumentCollection docCol = tab.AllDocuments;
// get main document
Document doc = tab.MainDocument;
if (docCol.Count <= 0) return -1
int index = docCol.Count / 2;
// insert main document to collection
docCol.Insert(doc, index);Example2
// get all documents
$docCol = $tab->AllDocuments;
// get main document
$doc = $tab->MainDocument;
if ($docCol->Count <= 0) return -1
$index = $docCol=>Count / 2;
// insert main document to collection
$docCol->Insert($doc, $index);InsertRange
Method
Inserts the documents of a collection into the DocumentCollection at the specified index.
If index is equal to Count, the elements are added to the end of DocumentCollection. The order of the elements in the collection is preserved in the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
index | The zero-based index at which the new documents should be inserted. |
documents | The collection whose elements should be inserted into the DocumentCollection. The collection itself cannot be null. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from zennolab.com
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// go to lessons.zennolab.com
DocumentCollection newDocCol = tab.AllDocuments;
// insert second collection to first collection start with 0 index
docCol.InsertRange(newDocCol, 0);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from zennolab.com
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// go to lessons.zennolab.com
$newDocCol = $tab->AllDocuments;
// insert second collection to first collection start with 0 index
$docCol->InsertRange($newDocCol, 0);
return 0;
}InsertRange
Method
Inserts the documents of an array into the DocumentCollection at the specified index.
If index is equal to Count, the elements are added to the end of DocumentCollection. The order of the elements in the collection is preserved in the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
index | The zero-based index at which the new documents should be inserted. |
documents | The array whose elements should be inserted into the DocumentCollection. The array itself cannot be null. |
Example
public static int Execute(Instance instance, IZennoPosterProjectModel project)
{
// clear cookie
instance.ClearCookie();
// go to zennolab.com
Tab tab = instance.MainTab;
if ((tab.IsVoid) || (tab.IsNull)) return -1;
if (tab.IsBusy) tab.WaitDownloading();
tab.Navigate("zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// get all documents from zennolab.com
DocumentCollection docCol = tab.AllDocuments;
// go to lessons.zennolab.com
tab.Navigate("lessons.zennolab.com");
if (tab.IsBusy) tab.WaitDownloading();
// go to lessons.zennolab.com
DocumentCollection newDocCol = tab.AllDocuments;
// insert second collection to first collection start with 0 index
docCol.InsertRange(newDocCol.Documents, 0);
return 0;
}Example2
public static function Execute($instance, $project)
{
// clear cookie
$instance->ClearCookie();
// go to zennolab.com
$tab = $instance->MainTab;
if (($tab->IsVoid) || ($tab->IsNull)) return -1;
if ($tab->IsBusy) $tab->WaitDownloading();
$tab->Navigate("zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// get all documents from zennolab.com
$docCol = $tab->AllDocuments;
// go to lessons.zennolab.com
$tab->Navigate("lessons.zennolab.com");
if ($tab->IsBusy) $tab->WaitDownloading();
// go to lessons.zennolab.com
$newDocCol = $tab->AllDocuments;
// insert second collection to first collection start with 0 index
$docCol->InsertRange($newDocCol->Documents, 0);
return 0;
}Remove
Method
Removes the element at the specified index of the DocumentCollection.
Parameters
| Параметр | Описание |
|---|---|
index | The zero-based index of the document to remove. |
Example
// get all documents from page
DocumentCollection docCol = tab.AllDocuments;
// remove the last document
docCol.Remove(docCol.Count-1);Example2
// get all documents from page
$docCol = $tab->AllDocuments;
// remove the last document
$docCol->Remove($docCol->Count-1);IndexOf
Method
Searches for the specified object and returns the zero-based index of the first occurrence within the entire DocumentCollection.
The DocumentCollection is searched forward starting at index and ending at the last element.
Parameters
| Параметр | Описание |
|---|---|
document | The document to locate in the DocumentCollection. |
Returns: The zero-based index of the first occurrence of item within the entire DocumentCollection, if found; otherwise, –1.
Example
// get main document
Document doc = tab.MainDocument;
// get index of main document in document collection of current web page
int index = docCol.IndexOf(doc);Example2
// get main document
$doc = $tab->MainDocument;
// get index of main document in document collection of current web page
$index = $docCol->IndexOf($doc);GetNull
Method
Возвращает пустой элемент
Fields
_zpIds
Field
id документов, которые находятся в этой коллекции