ResourceManagementClientGetResourceByKey Method (String, String, Object, CultureInfo) |
Gets a resource from the resource management service using a unique attribute and value combination, retrieving all 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,
string attributeName,
Object value,
CultureInfo locale
)
Public Function GetResourceByKey (
objectType As String,
attributeName As String,
value As Object,
locale As CultureInfo
) As ResourceObject
public:
ResourceObject^ GetResourceByKey(
String^ objectType,
String^ attributeName,
Object^ value,
CultureInfo^ locale
)
Parameters
- objectType
- Type: SystemString
The type of object to retrieve - attributeName
- Type: SystemString
The name of the attribute used as the key - value
- Type: SystemObject
The value of the attribute - 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 its AccountName attribute
public ResourceObject GetPersonByUsername(string username)
{
ResourceManagementClient client = new ResourceManagementClient();
List<string> attributesToGet = new List<string>() { "DisplayName", "FirstName", "LastName" };
try
{
ResourceObject resource = client.GetResourceByKey("Person", "AccountName", username, attributesToGet);
if (resource == null)
{
throw new ResourceNotFoundException();
}
return resource;
}
catch (TooManyResultsException)
{
throw;
}
}
See Also