Exemplo n.º 1
0
        /// <summary>
        /// From the serializable.
        /// </summary>
        /// <param name="memberAssignmentRepresentation">The memberAssignment.</param>
        /// <returns>
        /// Converted version.
        /// </returns>
        public static MemberAssignment FromRepresentation(
            this MemberAssignmentRepresentation memberAssignmentRepresentation)
        {
            if (memberAssignmentRepresentation == null)
            {
                throw new ArgumentNullException(nameof(memberAssignmentRepresentation));
            }

            var type = memberAssignmentRepresentation.Type.ResolveFromLoadedTypes();

            var member = type.GetMembers().Single(_ => _.ToRepresentation().Equals(memberAssignmentRepresentation.MemberInfo));

            var expression = memberAssignmentRepresentation.ExpressionRepresentation.FromRepresentation();

            var result = Expression.Bind(member, expression);

            return(result);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Converts to serializable.
        /// </summary>
        /// <param name="memberAssignment">The memberAssignment.</param>
        /// <returns>
        /// Serializable version.
        /// </returns>
        public static MemberAssignmentRepresentation ToRepresentation(
            this MemberAssignment memberAssignment)
        {
            if (memberAssignment == null)
            {
                throw new ArgumentNullException(nameof(memberAssignment));
            }

            var type = memberAssignment.Member.DeclaringType.ToRepresentation();

            var expression = memberAssignment.Expression.ToRepresentation();

            var memberInfoRepresentation = memberAssignment.Member.ToRepresentation();

            var result = new MemberAssignmentRepresentation(type, memberInfoRepresentation, expression);

            return(result);
        }