コード例 #1
0
        public void SerializeCall(Stream stream, IMethodBinder info, string target, MethodCall call)
        {
            var writer = XmlWriter.Create(stream);

            writer.WriteStartElement("MethodCall");
            writer.WriteElementString("Target", target);
            writer.WriteElementString("MethodSignature", Convert.ToBase64String(info.GetMethodSignature(call.Method)));

            writer.WriteStartElement("Arguments");
            var ctx = Cache.GetContext();


            var parameters = call.Method.GetParameters();

            for (int i = 0; i < parameters.Length; i++)
            {
                var parameter  = parameters[i];
                var serializer = ctx[parameter.ParameterType];
                var container  = serializer.Create();
                container.Value = call.Arguments[i];
                serializer.Serializer.Serialize(writer, container);
            }
            writer.WriteEndElement();
            writer.WriteEndElement();
            writer.Flush();
        }
コード例 #2
0
        public void SerializeCall(Stream stream, IMethodBinder binder, string target, MethodCall call)
        {
            var sig = binder.GetMethodSignature(call.Method);

            using (var writer = CreateWriter(stream))
            {
                writer.WriteStartObject();
                writer.WritePropertyName("Target");
                writer.WriteValue(target);
                writer.WritePropertyName("MethodSignature");
                writer.WriteValue(_useBson ? (object)sig : Convert.ToBase64String(sig));
                writer.WritePropertyName("Arguments");
                _serializer.Serialize(writer, call.Arguments);
                writer.WriteEndObject();
            }
        }