private static ExpressionSerialization.ExpressionSerializer GetSerializer(IEnumerable <Assembly> knownTypeAssemblies) { ExpressionSerialization.ExpressionSerializer s = new ExpressionSerialization.ExpressionSerializer( new ExpressionSerialization.TypeResolver(knownTypeAssemblies), new List <ExpressionSerialization.CustomExpressionXmlConverter>() { new CustomSerializer(knownTypeAssemblies) }); return(s); }
public static Expression Deserialize(XElement serializedExpression, IEnumerable <Assembly> knownTypeAssemblies) { if (serializedExpression == null) { throw new ArgumentNullException("serializedExpression"); } ExpressionSerialization.ExpressionSerializer s = GetSerializer(knownTypeAssemblies); Expression ex = s.Deserialize(serializedExpression); return(ex); }
public static XElement Serialize(Expression ex, IEnumerable <Assembly> knownTypeAssemblies) { if (ex == null) { throw new ArgumentNullException("ex"); } ExpressionSerialization.ExpressionSerializer s = GetSerializer(knownTypeAssemblies); ex = ExpressionSerialization.Evaluator.PartialEval(ex); XElement serializedExpression = s.Serialize(ex); return(serializedExpression); }