예제 #1
0
 private static string UrlEncode(string value)
 {
     if (string.IsNullOrWhiteSpace(value))
     {
         return(value);
     }
     return(HttpUtilsInternal.UrlEncode(value));
 }
예제 #2
0
        /// <summary>
        /// The entity to query string.
        /// </summary>
        /// <param name="entityObject">
        /// The p setup.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string EntityToQueryString(object entityObject, bool isUpdateOperation = false)
        {
            if (entityObject == null)
            {
                return(null);
            }

            var cmdParams = new StringBuilder();

            foreach (var propertyInfo in entityObject.GetType().GetProperties(BindingFlags.Public | BindingFlags.Instance))
            {
                if (propertyInfo.GetCustomAttribute <SkipAttribute>() != null)
                {
                    continue;
                }

                var attributes = propertyInfo.GetCustomAttributes(typeof(SkipDuringUpdateAttribute), false);
                if (isUpdateOperation && attributes.Any())
                {
                    continue;
                }

                var propertyValue = propertyInfo.GetValue(entityObject, null);

                if (propertyValue == null)
                {
                    continue;
                }

                if (propertyValue is bool)
                {
                    propertyValue = propertyValue.Equals(true) ? 1 : 0;
                }
                else if (propertyValue is DateTime)
                {
                    if (propertyValue.Equals(DateTime.MinValue))
                    {
                        continue;
                    }

                    // propertyValue = ((DateTime)fieldValue).ToString(@"yyyy-MM-dd\THH:mm:ss.fffzzz");
                    propertyValue = ((DateTime)propertyValue).ToString(AdobeConnectProviderConstants.DateFormat);
                }
                else if (propertyValue is TimeSpan)
                {
                    if (propertyValue.Equals(TimeSpan.Zero))
                    {
                        continue;
                    }

                    propertyValue = ((TimeSpan)propertyValue).TotalMinutes;
                }
                else if (propertyValue is Enum)
                {
                    propertyValue = ((Enum)propertyValue).ToXmlString();
                }

                var propertyName = GetPropertyXmlName(propertyInfo);

                cmdParams.AppendFormat("&{0}={1}", propertyName, HttpUtilsInternal.UrlEncode(propertyValue.ToString()));
            }

            return(cmdParams.ToString());
        }
예제 #3
0
        public string BuildQueryParams()
        {
            var query = new StringBuilder(_values.Count * 25);

            foreach (KeyValuePair <string, string> value in _values)
            {
                //&field-id=x-tel-intercall-leader-pin&value=xxxxxx
                query.AppendFormat("&field-id={0}{1}&value={2}", _fieldPrefix, value.Key, HttpUtilsInternal.UrlEncode(value.Value));
            }
            return(query.ToString());
        }