39 lines
760 B
C#
39 lines
760 B
C#
using BS.Shared.DataContracts;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Runtime.Serialization;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BeWo.Service.Core
|
|
{
|
|
public static class ServiceValidator
|
|
{
|
|
public static void CheckSerializationError<T>(T data)
|
|
{
|
|
var serializer = new DataContractSerializer(typeof(T));
|
|
using (var ms = new MemoryStream())
|
|
{
|
|
serializer.WriteObject(ms, data);
|
|
}
|
|
}
|
|
|
|
public static bool TryCheckSerializationError<T>(T data)
|
|
{
|
|
try
|
|
{
|
|
CheckSerializationError(data);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
File.WriteAllText("C:\\temp\\wcf-serialisierungsfehler.txt", ex.ToString());
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
}
|
|
}
|