<commit_before>﻿using System;
using System.Linq.Expressions;
using Untech.SharePoint.Common.Data.QueryModels;

namespace Untech.SharePoint.Common.Data.Translators.Predicate
{
	internal static class CamlProcessorUtils
	{
		internal static FieldRefModel GetFieldRef(Expression node)
		{
			if (node.NodeType == ExpressionType.MemberAccess)
			{
				var memberNode = (MemberExpression)node;
				var objectNode = memberNode.Expression;
				if (objectNode != null && (objectNode.NodeType == ExpressionType.Convert || objectNode.NodeType == ExpressionType.ConvertChecked))
				{
					var convertNode = (UnaryExpression) objectNode;
					objectNode = convertNode.Operand;
				}
				if (objectNode != null && objectNode.NodeType == ExpressionType.Parameter)
				{
					return new FieldRefModel(memberNode.Member);
				}
			}
			throw InvalidQuery(node);
		}

		internal static Exception InvalidQuery(Expression node)
		{
			return new NotSupportedException(node.ToString());
		}
	}
}<commit_msg>refactoring<commit_after>﻿using System;
using System.Linq.Expressions;
using Untech.SharePoint.Common.Data.QueryModels;
using Untech.SharePoint.Common.Extensions;

namespace Untech.SharePoint.Common.Data.Translators.Predicate
{
	internal static class CamlProcessorUtils
	{
		internal static FieldRefModel GetFieldRef(Expression node)
		{
			if (node.NodeType == ExpressionType.MemberAccess)
			{
				var memberNode = (MemberExpression)node;
				var objectNode = memberNode.Expression;
				if (objectNode != null && objectNode.NodeType.In(new [] { ExpressionType.Convert, ExpressionType.ConvertChecked}))
				{
					var convertNode = (UnaryExpression) objectNode;
					objectNode = convertNode.Operand;
				}
				if (objectNode != null && objectNode.NodeType == ExpressionType.Parameter)
				{
					return new FieldRefModel(memberNode.Member);
				}
			}
			throw InvalidQuery(node);
		}

		internal static Exception InvalidQuery(Expression node)
		{
			return new NotSupportedException(node.ToString());
		}
	}
}
{'fraction_non_alphanumeric': 0.09854927463731866, 'fraction_numerical': 0.0, 'mean_word_length': 4.347593582887701, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6989285', 'n_tokens_mistral': 673, 'n_tokens_neox': 569, 'n_words': 115}