public void ToChannelMethodInvoke(byte[] data, ServiceChannelManager channelManager, out ServiceChannel channel, out int methodIndex, out object[] args)
        {
            BinaryDataReader reader = new BinaryDataReader(data);

            channel = channelManager[reader.ReadString()];
            if (channel == null)
            {
                methodIndex = -1;
                args        = null;
                return;
            }
            methodIndex = reader.ReadInt32();
            if (methodIndex < 0 || methodIndex >= channel.Provider.ServerOperations.Count)
            {
                methodIndex = -1;
                args        = null;
                return;
            }
            var method    = channel.Provider.ServerOperations[methodIndex];
            var parameter = method.GetParameters();

            args = new object[reader.ReadByte()];
            for (int i = 0; i < args.Length; i++)
            {
                args[i] = Formatter.Deserialize(parameter[i].ParameterType, reader.ReadBytes());
            }
        }
Ejemplo n.º 2
0
 public ServiceHost(ServiceBinding binding)
 {
     Binding = binding;
     Server  = new Server((ushort)binding.MainPort);
     Server.PreviewAccept   += PreviewAccept;
     Server.AcceptCompleted += Accept;
     ChannelManager          = new ServiceChannelManager();
     SetDataFormatter(new DataFormatter());
     Unity           = new ServiceUnity();
     InstanceManager = new HostInstanceManager(Unity);
     IOManager       = new MessageIOManager();
 }