ResourceManagementClientGetResourceByKey Method (String, DictionaryString, Object, IEnumerableString, CultureInfo) |
Gets a resource from the resource management service using a set of unique attribute and value combinations, retrieving the specified attributes for the resource
Namespace:
Lithnet.ResourceManagement.Client
Assembly:
Lithnet.ResourceManagement.Client (in Lithnet.ResourceManagement.Client.dll) Version: 1.0.6435.24467
Syntaxpublic ResourceObject GetResourceByKey(
string objectType,
Dictionary<string, Object> attributeValuePairs,
IEnumerable<string> attributesToGet,
CultureInfo locale
)
Public Function GetResourceByKey (
objectType As String,
attributeValuePairs As Dictionary(Of String, Object),
attributesToGet As IEnumerable(Of String),
locale As CultureInfo
) As ResourceObject
public:
ResourceObject^ GetResourceByKey(
String^ objectType,
Dictionary<String^, Object^>^ attributeValuePairs,
IEnumerable<String^>^ attributesToGet,
CultureInfo^ locale
)
Parameters
- objectType
- Type: SystemString
The type of object to retrieve - attributeValuePairs
- Type: System.Collections.GenericDictionaryString, Object
A list of attribute value pairs that make this object unique - attributesToGet
- Type: System.Collections.GenericIEnumerableString
The list of attributes to retrieve - locale
- Type: System.GlobalizationCultureInfo
The culture to use to request a localized version of the object
Return Value
Type:
ResourceObjectA resource that matches the specified criteria, or null of no object was found
ExceptionsException | Condition |
---|
TooManyResultsException | The method will throw this exception when more that one match was found for the specified criteria |
Examples
The following example shows how get a user by using the AccountName and Domain pair of anchor attributes
public ResourceObject GetPersonByUsernameAndDomain(string username, string domain)
{
ResourceManagementClient client = new ResourceManagementClient();
Dictionary<string, object> anchorPairs = new Dictionary<string, object>();
anchorPairs.Add("AccountName", username);
anchorPairs.Add("Domain", domain);
List<string> attributesToGet = new List<string>() { "DisplayName", "FirstName", "LastName" };
try
{
ResourceObject resource = client.GetResourceByKey("Person", anchorPairs, attributesToGet);
if (resource == null)
{
throw new ResourceNotFoundException();
}
return resource;
}
catch (TooManyResultsException)
{
throw;
}
}
See Also