Click or drag to resize

ResourceManagementClientGetResource Method (UniqueIdentifier)

Gets a resource from the resource management service, retrieving all attributes for the resource

Namespace:  Lithnet.ResourceManagement.Client
Assembly:  Lithnet.ResourceManagement.Client (in Lithnet.ResourceManagement.Client.dll) Version: 1.0.6435.24467
Syntax
public ResourceObject GetResource(
	UniqueIdentifier id
)

Parameters

id
Type: UniqueIdentifier
The ID of the resource to get

Return Value

Type: ResourceObject
The resource represented by the specified ID
Examples
The following example shows how to get an object from a reference value
Example
public ResourceObject GetResourceByReference()
{
    ResourceManagementClient client = new ResourceManagementClient();

    // Specify the list of attributes that we are interested in
    List<string> attributesToGet = new List<string>() { "DisplayName", "FirstName", "LastName" };

    try
    {
        ResourceObject resource = client.GetResourceByKey("Person", "AccountName", "user0001", attributesToGet);

        if (resource == null)
        {
            // The resource was not found, throw an exception
            throw new ResourceNotFoundException();
        }

        // Return the resource referenced by user0001's Manager attribute

        return client.GetResource(resource.Attributes["Manager"].ReferenceValue);
    }
    catch (TooManyResultsException)
    {
        // More than one match was found
        throw;
    }
}
See Also