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)); } }
internal static void LoadResouce(string cacheKey, string filePath) { cacheKey = cacheKey.ToUpper(); MessageResource res = SerializationUtility.LoadFromXml <MessageResource>(filePath); lock (s_SyncObj) { if (s_MessageResDictionary.ContainsKey(cacheKey)) { s_MessageResDictionary[cacheKey] = res; } else { s_MessageResDictionary.Add(cacheKey, res); } } }
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)); } }
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)); } }
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); }