コード例 #1
0
 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);
 }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
        }