public Stream GetResourceByKey(string objectType, string key, string keyValue) { try { ResourceManagementSchema.ValidateAttributeName(key); ResourceManagementSchema.ValidateObjectTypeName(objectType); CultureInfo locale = WebResponseHelper.GetLocale(); ResourceObject resource = Global.Client.GetResourceByKey(objectType, key, keyValue, locale); if (resource == null) { throw new ResourceNotFoundException(); } return(WebResponseHelper.GetResponse(resource, false)); } catch (WebFaultException) { throw; } catch (WebFaultException <Error> ) { throw; } catch (Exception ex) { ResourceManagementWebServicev2.HandleException(ex); throw; } }
public Stream GetResourceByKey(string objectType, string key, string keyValue) { ResourceObject resource; try { ResourceManagementSchema.ValidateAttributeName(key); ResourceManagementSchema.ValidateObjectTypeName(objectType); CultureInfo locale = GetLocaleFromParameters(); resource = Global.Client.GetResourceByKey(objectType, key, keyValue, locale); if (resource == null) { throw new ResourceNotFoundException(); } } catch (WebFaultException) { throw; } catch (WebFaultException <ExceptionData> ) { throw; } catch (ResourceNotFoundException) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.NotFound); } catch (ResourceManagementException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (ArgumentException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (Exception ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex); } return(ResourceManagementWebServicev1.GetResponse(resource)); }
public KeyValuePair <string, string[]> GetResourceAttributeByKey(string objectType, string key, string keyValue, string attribute) { try { ResourceManagementSchema.ValidateAttributeName(attribute); ResourceManagementSchema.ValidateObjectTypeName(objectType); CultureInfo locale = GetLocaleFromParameters(); ResourceObject resource = Global.Client.GetResourceByKey(objectType, key, keyValue, new List <string>() { attribute }, locale); if (resource == null) { throw new ResourceNotFoundException(); } object value = resource.Attributes[attribute].Value; List <string> valuesToReturn = new List <string>(); if (value is string) { valuesToReturn.Add(value as string); } else if (value is byte[]) { valuesToReturn.Add(Convert.ToBase64String((byte[])value)); } else { IEnumerable values = value as IEnumerable; if (values != null) { foreach (object enumvalue in values) { if (enumvalue is DateTime) { valuesToReturn.Add(((DateTime)enumvalue).ToResourceManagementServiceDateFormat()); } else if (enumvalue is byte[]) { valuesToReturn.Add(Convert.ToBase64String((byte[])enumvalue)); } else { valuesToReturn.Add(enumvalue.ToString()); } } } else { valuesToReturn.Add(value.ToString()); } } return(new KeyValuePair <string, string[]>(attribute, valuesToReturn.ToArray())); } catch (WebFaultException) { throw; } catch (WebFaultException <ExceptionData> ) { throw; } catch (ResourceNotFoundException) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.NotFound); } catch (ResourceManagementException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (ArgumentException ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.BadRequest, ex); } catch (Exception ex) { throw WebExceptionHelper.CreateWebException(HttpStatusCode.InternalServerError, ex); } }
/// <summary> /// Initializes a new instance of the XPathDereferencedExpression class /// </summary> /// <param name="objectType">The object type used in the expression</param> /// <param name="dereferenceAttribute">The name of the attribute to dereference</param> /// <param name="query">The query used to build the expression</param> /// <param name="wrapFilterXml">Indicates if the resulting expression should be wrapped in an XML filter element</param> public XPathDereferencedExpression(string objectType, string dereferenceAttribute, IXPathQueryObject query, bool wrapFilterXml) : base(objectType, query, wrapFilterXml) { this.DereferenceAttribute = dereferenceAttribute; ResourceManagementSchema.ValidateObjectTypeName(this.DereferenceAttribute); }