Exemplo n.º 1
0
        /// <summary>
        /// Create serialized http string content
        /// </summary>
        /// <param name="processType"></param>
        /// <param name="response"></param>
        /// <returns></returns>
        public static StringContent ToHttpContent(this Type processType, VoidResult response)
        {
            var attributes = processType.GetCustomAttributes(typeof(SignalsApiAttribute), false).Cast <SignalsApiAttribute>().ToList();

            foreach (var attribute in attributes)
            {
                if (attribute.ResponseType == SerializationFormat.Xml)
                {
                    return(new StringContent(response.SerializeXml(), System.Text.Encoding.UTF8, "application/xml"));
                }
                else if (attribute.ResponseType == SerializationFormat.Xml)
                {
                    return(new StringContent(response.SerializeJson(), System.Text.Encoding.UTF8, "application/json"));
                }
            }

            return(new StringContent(response.SerializeJson(), System.Text.Encoding.UTF8, "application/json"));
        }