Пример #1
0
        private static void Add(this TypedAttributeCollection attributeCollection, TypedAttribute typedAttribute)
        {
            //NOTE: Here we need to generate an id for this item.
            // Though Id generation should generally be performed by Hive providers, a TypedAttribute can exist without an
            // id in the repository when a AttributeDefinition is created on the Schema and there are no TypeEntity revisions
            // for that schema with the updated AttributeDefinition.
            if (typedAttribute.Id.IsNullValueOrEmpty())
            {
                typedAttribute.Id = new HiveId(Guid.NewGuid());
            }

            attributeCollection.Add(typedAttribute);
        }
Пример #2
0
        /// <summary>
        /// Sets
        /// </summary>
        /// <param name="attributeCollection"></param>
        /// <param name="typedAttribute"></param>
        public static void SetValueOrAdd(this TypedAttributeCollection attributeCollection, TypedAttribute typedAttribute)
        {
            var attribute = attributeCollection.SingleOrDefault(x => x.AttributeDefinition.Alias == typedAttribute.AttributeDefinition.Alias);

            if (attribute == null)
            {
                attributeCollection.Add(typedAttribute);
            }
            else
            {
                attribute.Values.Clear();
                typedAttribute.Values.ForEach(attribute.Values.Add);
            }
        }