Example #1
0
        private void TestMergeChangesForOrmAttribute <T>(T sourceAttribute, T targetAttribute) where T : IOrmAttribute
        {
            var targetGroupItems = targetAttribute.GetAttributeGroupItems(AttributeGroupsListMode.All);

            foreach (var attributeGroupItem in targetGroupItems)
            {
                attributeGroupItem.SetAsDefault();
            }

            bool   toXml = false;
            string xmlSource;
            string xmlTarget;

            if (toXml)
            {
                xmlSource = sourceAttribute.SerializeToString();
                xmlTarget = targetAttribute.SerializeToString();
            }

            IOrmAttribute mergedAttribute = sourceAttribute.MergeChanges(targetAttribute, MergeConflictAction.TakeOther);

            foreach (var attributeGroupsListMode in EnumType <AttributeGroupsListMode> .Values)
            {
                var sourceGroupItems = sourceAttribute.GetAttributeGroupItems(attributeGroupsListMode);
                var mergedGroupItems = mergedAttribute.GetAttributeGroupItems(attributeGroupsListMode);

                for (int i = 0; i < mergedGroupItems.Count; i++)
                {
                    var mergedGroupItem = mergedGroupItems[i];
                    var sourceGroupItem = sourceGroupItems[i];

                    Assert.IsTrue(mergedGroupItem.EqualsTo(sourceGroupItem));
                }
            }
        }
Example #2
0
        protected void Build()
        {
            foreach (var pair in attributeItems)
            {
                IOrmAttribute attribute     = pair.Key;
                AttrData      attributeData = pair.Value;

                foreach (var attributeGroup in attributeData.AttributeGroups)
                {
                    Dictionary <string, Defaultable> attributeGroupItems =
                        attribute.GetAttributeGroupItems(attributeGroup);

                    Prefilter(attribute, attributeGroupItems);

                    attributeData.AttributeGroupItems[attributeGroup] = attributeGroupItems;
                }
            }
        }