예제 #1
0
        protected virtual string SerializeRequestData(object data, RequestFormat format)
        {
            if (data == null)
            {
                return(null);
            }
            switch (format)
            {
            case RequestFormat.Json:
                return(SerializationUtility.JsonSerializeCommon(data));

            case RequestFormat.Xml:
                return(SerializationUtility.XmlSerialize(data));

            case RequestFormat.Raw:
                return(data.ToString());

            default:
                return(SerializationUtility.BinarySerialize(data));
            }
        }
예제 #2
0
        private static string GetMethodArgumentValue(object[] arguments)
        {
            if (arguments == null || arguments.Length == 0)
            {
                return("N/A");
            }
            string result = string.Empty;

            for (int i = 0; i < arguments.Length; i++)
            {
                if (arguments[i] != null)
                {
                    if (arguments[i] is string)
                    {
                        result += Convert.ToString(arguments[i]);
                    }
                    else if (arguments[i].GetType().IsPrimitive)
                    {
                        result += arguments[i].ToString();
                    }
                    else
                    {
                        try
                        {
                            result += SerializationUtility.XmlSerialize(arguments[i]);
                        }
                        catch
                        {
                            result += "[Xml Serialize Error]";
                        }
                    }
                    if (i != arguments.Length - 1)
                    {
                        result += ", ";
                    }
                }
            }
            return(result);
        }