public void TestCompression() { string inStr = SerializationManager.Serialize(gateway.FindArray <Order>()); string outGZip = CompressionManager.Compress(inStr); string out7Zip = CompressionManager.Compress7Zip(inStr); Console.WriteLine("Input Size: " + inStr.Length.ToString()); Console.WriteLine("GZip Output Size: " + outGZip.Length.ToString()); Console.WriteLine("7Zip Output Size: " + out7Zip.Length.ToString()); Assert.AreEqual(inStr.Length, CompressionManager.Decompress7Zip(out7Zip).Length); Assert.AreEqual(inStr.Length, CompressionManager.Decompress(outGZip).Length); }
/// <summary> /// Calls the service. /// </summary> /// <param name="subServiceName">Name of the sub service.</param> /// <param name="returnType">Type of the return.</param> /// <param name="paramValues">The param values.</param> /// <returns>The result.</returns> protected object CallService(string subServiceName, Type returnType, params object[] paramValues) { object errorReturnValue = null; if (returnType != typeof(void)) { errorReturnValue = Util.DefaultValue(returnType); } RequestMessage reqMsg = new RequestMessage(); reqMsg.Expiration = DateTime.Now.AddMinutes(DefaultExpireMinutes); reqMsg.MessageId = Guid.NewGuid(); reqMsg.ServiceName = serviceInterfaceType.FullName; reqMsg.SubServiceName = subServiceName; reqMsg.Timestamp = DateTime.Now; reqMsg.TransactionId = Guid.NewGuid(); MethodInfo mi = null; foreach (MethodInfo item in serviceInterfaceType.GetMethods()) { if (item.ToString() == subServiceName) { mi = item; break; } } if (mi == null) { foreach (Type inheritedInterface in serviceInterfaceType.GetInterfaces()) { foreach (MethodInfo item in inheritedInterface.GetMethods()) { if (item.ToString() == subServiceName) { mi = item; break; } } } } if (mi == null) { return(errorReturnValue); } ParameterInfo[] pis = mi.GetParameters(); if ((pis.Length == 0 && paramValues != null && paramValues.Length > 0) || (paramValues != null && pis.Length != paramValues.Length)) { return(errorReturnValue); } if (pis.Length > 0) { for (int i = 0; i < paramValues.Length; i++) { if (paramValues[i] == null) { continue; } string val = SerializationManager.Serialize(paramValues[i]); reqMsg.Parameters[pis[i].Name] = val; } } ResponseMessage resMsg = container.CallService(serviceInterfaceType.FullName, reqMsg); if (resMsg == null || returnType == typeof(void)) { return(errorReturnValue); } try { if (!container.Compress) { if (returnType == typeof(System.Data.DataSet)) { return(resMsg.Data); } else if (resMsg.Text != null) { return(SerializationManager.Deserialize(returnType, resMsg.Text)); } } else { string retText = CompressionManager.Decompress7Zip(resMsg.Text); if (retText != null) { return(SerializationManager.Deserialize(returnType, retText)); } } } catch { } return(errorReturnValue); }