Ejemplo n.º 1
0
        private static byte[] SerializeServiceExceptionData(ServiceExceptionData msg)
        {
            if (msg == null)
            {
                return(null);
            }

            using var stream = new MemoryStream();
            using var writer = XmlDictionaryWriter.CreateBinaryWriter(stream);
            ServiceExceptionDataSerializer.WriteObject(writer, msg);
            writer.Flush();
            return(stream.ToArray());
        }
Ejemplo n.º 2
0
        internal static bool TryDeserializeExceptionData(Stream data, out ServiceExceptionData result)
        {
            try
            {
                var exceptionData = (ServiceExceptionData)DeserializeServiceExceptionData(data);
                result = exceptionData;
                return(true);
            }
            catch (Exception e)
            {
                // swallowing the exception
                ActorTrace.Instance.WriteWarning(
                    "RemoteException",
                    " ServiceExceptionData DeSerialization failed : Reason  {0}",
                    e);
            }

            result = null;
            return(false);
        }
Ejemplo n.º 3
0
        internal static bool TryDeserializeExceptionData(Stream data, out ServiceExceptionData result, ILogger logger = null)
        {
            try
            {
                var exceptionData = (ServiceExceptionData)DeserializeServiceExceptionData(data);
                result = exceptionData;
                return(true);
            }
            catch (Exception e)
            {
                // swallowing the exception
                logger?.LogWarning(
                    "RemoteException",
                    " ServiceExceptionData DeSerialization failed : Reason  {0}",
                    e);
            }

            result = null;
            return(false);
        }
Ejemplo n.º 4
0
        internal static byte[] FromExceptionString(Exception exception)
        {
            var exceptionStringBuilder = new StringBuilder();

            exceptionStringBuilder.AppendFormat(
                CultureInfo.CurrentCulture,
                SR.ErrorExceptionSerializationFailed1,
                exception.GetType().FullName);

            exceptionStringBuilder.AppendLine();

            exceptionStringBuilder.AppendFormat(
                CultureInfo.CurrentCulture,
                SR.ErrorExceptionSerializationFailed2,
                exception);
            var exceptionData = new ServiceExceptionData(exception.GetType().FullName, exceptionStringBuilder.ToString());

            var exceptionBytes = SerializeServiceExceptionData(exceptionData);

            return(exceptionBytes);
        }