<commit_before>﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CsomInspector.Core
{
	public class Result
	{
		protected Result(Int32 actionId, IEnumerable<ResultProperty> properties)
		{
			ActionId = actionId;
			Properties = properties;
		}

		public static IEnumerable<Result> FromJson(IEnumerable<JToken> tokens)
		{
			var resultsCount = tokens.Count() / 2;

			for (int i = 0; i < resultsCount; i++)
			{
				var actionId = tokens
					.Skip(i * 2)
					.First()
					.Value<Int32>();

				var resultToken = tokens
					.Skip(i * 2)
					.Skip(1)
					.First();

				var properties = ResultProperty.FromJson(resultToken.Children());

				yield return new Result(actionId, properties);
			}
		}

		public Int32 ActionId { get; private set; }

		public IEnumerable<ResultProperty> Properties { get; private set; }
	}

	public class ResultProperty : IObjectTreeNode
	{
		protected ResultProperty(String name, String value)
		{
			Name = name;
			Value = value;
		}

		protected ResultProperty(String name, IEnumerable<IObjectTreeNode> children)
		{
			Name = name;
			Children = children;
		}

		public IEnumerable<IObjectTreeNode> Children { get; private set; }

		public String Name { get; private set; }

		public String Value { get; private set; }

		public override String ToString()
		{
			if (!String.IsNullOrWhiteSpace(Value))
			{
				return $"{Name}: {Value}";
			}

			return $"{Name}";
		}

		public static IEnumerable<ResultProperty> FromJson(JEnumerable<JToken> tokens)
		{
			foreach (var token in tokens)
			{
				var name = token.Path;
				var child = token.Children().FirstOrDefault();
				var value = child?.ToString();

				yield return new ResultProperty(name, value);
			}
		}
	}
}<commit_msg>Format object identity in result window #17<commit_after>﻿using CsomInspector.Core.ObjectPaths;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;

namespace CsomInspector.Core
{
	public class Result
	{
		protected Result(Int32 actionId, IEnumerable<ResultProperty> properties)
		{
			ActionId = actionId;
			Properties = properties;
		}

		public static IEnumerable<Result> FromJson(IEnumerable<JToken> tokens)
		{
			var resultsCount = tokens.Count() / 2;

			for (int i = 0; i < resultsCount; i++)
			{
				var actionId = tokens
					.Skip(i * 2)
					.First()
					.Value<Int32>();

				var resultToken = tokens
					.Skip(i * 2)
					.Skip(1)
					.First();

				var properties = ResultProperty.FromJson(resultToken.Children());

				yield return new Result(actionId, properties);
			}
		}

		public Int32 ActionId { get; }

		public IEnumerable<ResultProperty> Properties { get; }
	}

	public class ResultProperty : IObjectTreeNode
	{
		protected ResultProperty(String name, String value)
		{
			Name = name;
			Value = value;
		}

		protected ResultProperty(String name, IEnumerable<IObjectTreeNode> children)
		{
			Name = name;
			Children = children;
		}

		public IEnumerable<IObjectTreeNode> Children { get; }

		public String Name { get; }

		public String Value { get; }

		public override String ToString()
		{
			if (!String.IsNullOrWhiteSpace(Value))
			{
				return $"{Name}: {Value}";
			}

			return $"{Name}";
		}

		public static IEnumerable<ResultProperty> FromJson(JEnumerable<JToken> tokens)
		{
			foreach (var token in tokens)
			{
				var property = token as JProperty;
				var child = token.Children().FirstOrDefault();
				var value = child?.ToString();

				if (String.Equals(property.Name, "_ObjectIdentity_", StringComparison.InvariantCultureIgnoreCase))
				{
					var identity = IdentityParameter.FromIdentityString(value);

					yield return new ResultProperty(property.Name, identity);
				}
				else
				{
					yield return new ResultProperty(property.Name, value);
				}
			}
		}
	}
}
{'fraction_non_alphanumeric': 0.10926118626430802, 'fraction_numerical': 0.006243496357960458, 'mean_word_length': 3.3993135011441646, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, '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': '2265942', 'n_tokens_mistral': 1453, 'n_tokens_neox': 1161, 'n_words': 307}