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> /// Runs the specified MSG. /// </summary> /// <param name="msg">The MSG.</param> /// <returns>The msg.</returns> protected override ResponseMessage Run(RequestMessage msg) { if (container == null || msg == null) { return(null); } object service = default(object); try { service = container[serviceInterfaceType]; } catch { } if (service == null) { return(null); } MethodInfo mi = null; foreach (MethodInfo item in serviceInterfaceType.GetMethods()) { if (msg.SubServiceName == item.ToString()) { mi = item; break; } } if (mi == null) { foreach (Type inheritedInterface in serviceInterfaceType.GetInterfaces()) { foreach (MethodInfo item in inheritedInterface.GetMethods()) { if (item.ToString() == msg.SubServiceName) { mi = item; break; } } } } if (mi == null) { return(null); } ParameterInfo[] pis = mi.GetParameters(); object[] parms = new object[pis.Length]; for (int i = 0; i < pis.Length; i++) { Type type = pis[i].ParameterType; object val = SerializationManager.Deserialize(type, msg.Parameters[pis[i].Name]); parms[i] = val; } ResponseMessage resMsg = new ResponseMessage(); resMsg.Request = msg; resMsg.Expiration = DateTime.Now.AddMinutes(DefaultExpireMinutes); resMsg.MessageId = Guid.NewGuid(); resMsg.ServiceName = serviceInterfaceType.FullName; resMsg.SubServiceName = mi.Name; resMsg.Timestamp = DateTime.Now; resMsg.TransactionId = msg.TransactionId; object returnValue = null; try { returnValue = mi.Invoke(service, parms); } catch { return(null); } if (returnValue != null) { Type returnType = mi.ReturnType; if (!container.Compress) { if (returnType == typeof(System.Data.DataSet)) { resMsg.Data = (DataSet)returnValue; } else { resMsg.Text = SerializationManager.Serialize(returnValue); } } else { string retText; if (returnType == typeof(System.Data.DataSet)) { retText = SerializationManager.Serialize(returnValue); } else { retText = SerializationManager.Serialize(returnValue); } resMsg.Text = CompressionManager.Compress7Zip(retText); } } return(resMsg); }