/// <summary>
        /// Sets the internal attribute value collection with the initial values contained in the dictionary
        /// </summary>
        /// <param name="values">The initial attributes and values to set</param>
        /// <param name="permissions">The permission hints for the attributes</param>
        private void SetInitialAttributeValues(Dictionary <string, List <string> > values, Dictionary <string, AttributePermission> permissions)
        {
            this.attributes         = new AttributeValueCollection();
            this.HasPermissionHints = false;

            foreach (KeyValuePair <string, List <string> > kvp in values)
            {
                string attributeName      = kvp.Key;
                AttributeTypeDefinition d = this.ObjectType[attributeName];
                AttributePermission     p = AttributePermission.Unknown;

                if (permissions != null)
                {
                    if (permissions.ContainsKey(attributeName))
                    {
                        p = permissions[attributeName];

                        if (p != AttributePermission.Unknown)
                        {
                            this.HasPermissionHints = true;
                        }
                    }
                }

                if (d != null)
                {
                    if (!d.IsMultivalued && kvp.Value.Count > 1)
                    {
                        throw new InvalidOperationException($"The attribute {d.SystemName} is listed in the schema as a multivalued attribute, but more than one value was returned");
                    }

                    if (kvp.Value.Count == 0)
                    {
                        this.attributes.Add(d.SystemName, new AttributeValue(d, p));
                        continue;
                    }

                    if (d.IsMultivalued)
                    {
                        this.attributes.Add(d.SystemName, new AttributeValue(d, p, kvp.Value));
                    }
                    else
                    {
                        this.attributes.Add(d.SystemName, new AttributeValue(d, p, kvp.Value.First()));
                    }

                    if (d.SystemName == AttributeNames.Locale)
                    {
                        this.Locale = new CultureInfo(kvp.Value.First());
                    }
                }
            }

            this.AddRemainingAttributesFromSchema();
        }
 /// <summary>
 /// Initializes a new instance of the AttributeValue class
 /// </summary>
 /// <param name="type">The definition of the attribute to hold the values for</param>
 /// <param name="permission">The user's permission on this attribute, if known</param>
 internal AttributeValue(AttributeTypeDefinition type, AttributePermission permission)
     : this(type, permission, null)
 {
 }