集合
集合是本身包含了许多对象的对象集,所有的集合都包含一些预定义的方法和属性.一个集合有一个Item方法,一个Count属性,一个 _NewEnum方法.集合有建立类型与他相同的对象的能力.换句话说,如果一个对象可以被包含进一个集合中,那么,哎,这句话好难,我不翻了,给出原文吧.( In other words, if a particular object can be group in a set then that object will have a collection object that can create an instance of an object within the set. For instance, a Drives collection object will contain a set of drives that might represent all the drives on a particular computer).
(以下不译)
Notice that the _NewEnum method is not referenced within the syntax of the
statement in example 6. This is because the _NewEnum method has a special
index that Visual Basic recognizes as being used for the For Next statement. As a
little background, all methods and properties in a COM object are indexed and
certain indexes are used for particular tasks. For example the zero index is used
for the default method or property.
The Default Method or Property
The method or property that has the COM index of zero is called the default
property. Visual Basic allows the programmer to not use the regular
method/property syntax when calling the default value, you can leave the
syntactical call to the method/property off all together. For example, the default
method in all collections is the Item method. If you where going to call the Item
method, you could do it like it in example 9.
(以下不译)
The Documentation
Now that we have established the understanding between methods and properties
along with their different attributes, we need to understand how the documentation
for the objects represents these attributes. For examples, we are going to look at
15 Seconds' component section, which is in the same format as the IIS 4.0
component documentation.
Read and Write Properties
A good example of a read/write property is that of the PhoneTranslate property of
the XCheck object, shown here in example 11:
Example 13
object.PhoneTranslate[= value]
Notice the value syntax, this is the indication of a property that can be written to.
The brackets denote that the property is optional, in other words you do not need
to set the property to use the object. Click here to view the full documentation.
Read Only Properties
A good example of a read only property is the Expires property of the ASPMail
object.
Example 14
object.Expires
Notice that unlike example 11 there is not an equal symbol, indicating this is read
only. Click here to view the full documentation.
Optional Method Arguments
A good example of the optional arguments is the SendX method of the OCXMail
object. The documentation syntax can be seen here in example 12:
Example 12
object.SendX(mailserver[, fromName[, fromAddress[, priority[,
returnReceipt[, toAddressList[, ccAddressList[, bccAddressList[,
attach[, messageSubject[, messageText]]]]]]]]]])
Notice that the only required argument is the mailserver argument. All the rest,
noted by the brackets are optional. Click here to view the full documentation.
Summary
With a fundamental understanding of COM and it's abilities, coupled with good
documentation you can expand the flexibility of your Active Server page
programming. Take the information that you already know about programming IIS
objects, like Session objects and AD