/// <summary>
        /// Processes the condition values.
        /// </summary>
        /// <param name="typedValues">The typed values.</param>
        /// <returns>Dictionary{System.Int64System.String}.</returns>
        private Dictionary <long, string> ProcessConditionValues(IEnumerable <TypedValue> typedValues)
        {
            Dictionary <long, string> values = new Dictionary <long, string>();

            foreach (TypedValue typedValue in typedValues)
            {
                long entityId;
                if (!long.TryParse(typedValue.ValueString, out entityId))
                {
                    continue;
                }
                Entity entity = Entity.Get <Entity>(entityId);
                values[entityId] = entity.GetField("core:name") as string;
            }
            return(values.Count > 0 ? values : null);
        }
        /// <summary>
        /// Construct the message written to the <see cref="MessageContext"/>.
        /// </summary>
        /// <param name="entities"></param>
        /// <param name="subjects"></param>
        /// <param name="entityTypes"></param>
        /// <param name="subject"></param>
        /// <param name="entityType"></param>
        /// <returns></returns>
        private string ConstructCheckMessage(IList <EntityRef> entities, ISet <long> subjects, IDictionary <long, ISet <EntityRef> > entityTypes,
                                             long subject, KeyValuePair <long, ISet <EntityRef> > entityType)
        {
            EntityRef nameField;

            nameField = new EntityRef("core", "name");

            // Preload names of referenced entities, subjects and types
            Entity.GetField <string>(subjects.Select(e => new EntityRef(e)), nameField);
            // This was failing because the entities were instances of EntityTypeOnly which were causing failures when passes into Entity.GetField
            Entity.GetField <string>(entities.Where(e => !EntityId.IsTemporary(e.Id)).Select(e => new EntityRef(e.Id)), nameField);
            Entity.GetField <string>(entityTypes.Keys.Select(e => new EntityRef(e)), nameField);

            return(string.Format(
                       "Checking access rules for {0} to entities {1} of type {2}:",
                       string.Format("'{0}' ({1})", Entity.GetName(subject), subject),
                       string.Join(
                           ", ",
                           entityType.Value.Select(er => string.Format("'{0}' ({1})", Entity.GetName(er.Id), er.Id))),
                       string.Join(
                           ", ",
                           string.Format("'{0}' ({1})", Entity.GetName(entityType.Key), entityType.Key))));
        }