集合
集合是本身包含了許多個物件的對象集,所有的集合都包含一些預定義的方法和屬性.一個集合有一個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 ADO, and expand on that by adding more
COM objects to your repertoire. Third party COM object will allow you to
expand your Active server applications and accomplish tasks rapidly by leveraging
the component object model.