The SiteManager contains a dictionary of Object Manager types with an entry for each specific object type (IDocumentManager for IDocument type, etc.)

Each Object Manager handles the retrieval and manipulation of its underlying type object, within the secure context of the SiteManager that is holding it.

The Object Manager instance will only belong to one SiteManager instance.

The ICommentManager is used here as an example demonstrating retrieval of an IComment object instance.

Retrieving an object instance with its manager.

  1. Retrieve the Object Manager instance from SiteManager. This can be done by manager type or by object type. Both support a generic and non-generic syntax.

    CopyC#
    //Retrieve comment manager by manager type via generic syntax.
    //The generic argument can be either interface type or object type.
    ICommentManager commentManager = siteManager.GetManager<ICommentManager>();
    CopyC#
    //Retrieve comment manager by manager type via non-generic syntax.
    //Non-generic syntax will return ICartellaObjectManager type, which must be
    //cast to your target type.
    ICommentManager commentManager = siteManager.GetManager(typeof(ICommentManager)) as ICommentManager;
    CopyC#
    //Retrieve comment manager by IComment object type via generic syntax.
    //Two arguments must be passed in: Manager return type and Object type.
    ICommentManager commentManager = siteManager.GetManagerForObjectType<ICommentManager, IComment>();
    CopyC#
    //Retrieve comment manager by IComment object type via non-generic syntax.
    //Non-generic syntax returns an ICartellaObjectManager type, which must be
    //cast to your target type.
    ICommentManager commentManager = siteManager.GetManagerForObjectType(typeof(IComment)) as ICommentManager;
  2. Use the Object Manager to retrieve an object instance. Each manager will have its own unique way of retrieving its objects, inheriting the method from the parent class. Using the specific Object Manager method is recommended.

    CopyC#
    //Select a single comment using the CommentManager
    string commentId = "42354545";
    IComment comment = commentManager.SelectSingleComment(commentId);

Retrieving an object directly from the SiteManager

The SiteManager also provides a generic method to select an object or objects of a specific type. The following example demonstrates how:
CopyC#
//Select a single comment using the SiteManager
//Please note that the generic argument passed in must be a concrete and known type (non abstract class)
string commentId = "42354545";
IComment comment = siteManager.SelectSingleObject<Comment>(commentId) as IComment;

See Also

Reference