Ejemplo n.º 1
0
        void LoopCore()
        {
            var uri = new Uri(_uri);

            var protocolInfo = GetProtocolInfo(uri);

            if (protocolInfo == null)
            {
                return;
            }

            var ret = _control.Execute(protocolInfo);

            SendReturnInfo(uri, ret);
        }
Ejemplo n.º 2
0
        void LoopCore()
        {
            var context = _listener.GetContext();

            using (var response = context.Response)
            {
                ProtocolInfo protocolInfo;
                using (var reader = new StreamReader(context.Request.InputStream))
                {
                    string protocol;
                    protocol = reader.ReadToEnd();
                    if (string.IsNullOrEmpty(protocol))
                    {
                        return;
                    }
                    using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(protocol)))
                    {
                        var serializer = new DataContractSerializer(typeof(ProtocolInfo), AssemblyManager.GetDataContractableTypes());
                        protocolInfo = (ProtocolInfo)serializer.ReadObject(ms);
                    }
                }


                var returnInfo = _control.Execute(protocolInfo);


                byte[] bin = null;
                using (var ms = new MemoryStream())
                {
                    var serializer = new DataContractSerializer(returnInfo.GetType(), AssemblyManager.GetDataContractableTypes());
                    serializer.WriteObject(ms, returnInfo);
                    bin = ms.ToArray();
                }
                response.OutputStream.Write(bin, 0, bin.Length);
            }
        }