Beispiel #1
0
        private static string GetObjectValueAsKey(object obj)
        {
            Type type = obj.GetType();

            if (s_IdentityType.IsAssignableFrom(type))
            {
                return(Invoker.PropertyGet(s_IdentityType, obj, "SysNo", false, true).ToString());
            }
            else if (CanAsKey(type))
            {
                return(obj.ToString());
            }
            else
            {
                return(SerializationUtility.BinarySerialize(obj));
            }
        }
Beispiel #2
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));
            }
        }
Beispiel #3
0
        protected virtual object DeserializeResponseData(string responseTxt, RequestFormat format, Type type)
        {
            if (responseTxt == null || responseTxt.Trim().Length <= 0)
            {
                return(null);
            }
            switch (format)
            {
            case RequestFormat.Json:
                return(SerializationUtility.JsonDeserialize(responseTxt, type));

            case RequestFormat.Xml:
                return(SerializationUtility.XmlDeserialize(responseTxt, type));

            case RequestFormat.Raw:
                return(responseTxt);

            default:
                return(SerializationUtility.BinaryDeserialize(responseTxt));
            }
        }
Beispiel #4
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);
        }