The LinkDescriptor component is used to specify a relationship between the current object store item to be added, and previously added items, during an Add or AddViaTemplate operation. A list of LinkDescriptor components is passed as an input argument to these commands, where each component represents a link to be created. The client is able to specify the object store item to be linked, the link class to use when creating the Link object, the relationship between the two linked objects, and optional additional properties to include in the link object.
coclass LinkDescriptor {
[default] interface ILinkDescriptor;
};
DLL | FnAppIntCmdComponents.dll |
See Also | Add and AddViaTemplate commands |
The ILinkDescriptor interface defines the following methods:
Method | Description |
---|---|
GetLinkClassId | Returns the class ID of the link item. |
GetObjectStoreItem | Provides the client application with access to the item type, version ID and version series ID of the link item. |
GetPropertiesXml | Returns the XML properties associated with the link item. |
GetRelationshipType | Returns the location of the link item relative to the other linked objects. |
Initialize | Initializes the LinkDescriptor component with the object store item to be linked, the link class to apply to the linked object, and the location of the linked object to the other links (that is, whether the link is the head or the tail in the list). |
The following is a fragment from the complete example for the Add command, which utilizes an LinkDescriptor component.
... // Create the LinkDescriptors for the item to Add const DWORD cNumElements = 2; long lCount = 0; COleSafeArray saLinks(VT_DISPATCH, cNumElements); { // Instantiate a LinkDescriptor component
ILinkDescriptorPtr spILinkDescriptor0(__uuidof(LinkDescriptor)); _ASSERTE(spILinkDescriptor != 0); // Instantiate the ObjectStoreItem component IObjectStoreItemPtr spIObjectStoreItem0; hResult = spIObjectStoreItem0.CreateInstance(__uuidof(ObjectStoreItem));
if (FAILED(hResult)) {
std::cout << "Could not create the ObjectStoreItem component.\n"; _ASSERTE(0);
} // Initialize the ObjectStoreItem component with // the items' type, name, version series ID and version ID. ItemType eItemType = eItemTypeDocument; _bstr_t bstrObjectStoreName = (_T("Alaska")); _bstr_t bstrVersionSeriesID = (_T("{6BC064A2-2D58-4B0A-AEF2-B2F8A1100000}")); _bstr_t bstrVersionID = (_T("{DDE54469-36D9-4fe9-8676-445E4994DE1F}")); std::cout << "Initializing the ObjectStoreItem component..." << std::endl;
spIObjectStoreItem0->Initialize(eItemType, bstrObjectStoreName, bstrVersionSeriesID, bstrVersionID); // Create a Related Items class of link object _bstr_t bstrLinkClassID = (_T("{C91111A9-CE9C-43e6-8548-8A08F43F9726}")); RelationshipType enLinkType = eTypeLinkTo; // Define the XML properties for the item to Link std::cout << "Defining the XML item properties..." << std::endl; _bstr_t bstrLinkPropertiesXml = _T( "" ); bstrLinkPropertiesXml += _T("<properties>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>DocumentTitle</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>LinkedDocument.doc</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>Description</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>This will be a linked document.</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("<property>");
bstrLinkPropertiesXml += _T("<symname>Title</symname>"); bstrLinkPropertiesXml += _T("<values>");
bstrLinkPropertiesXml += _T("<value>First Related Item</value></values>");
bstrLinkPropertiesXml += _T("</property>");
bstrLinkPropertiesXml += _T("</properties>");
// Initialize the LinkDescriptor component to hold the link std::cout << "Initializing LinkDescriptor component 1..." << std::endl; spILinkDescriptor0->Initialize(spIObjectStoreItem0, bstrLinkClassID, enLinkType, bstrLinkPropertiesXml); if(spILinkDescriptor0) { saLinks.PutElement(&lCount, spILinkDescriptor0); } } ...