Example #1
0
        public IEnumerable <AttributeSpec> GetAllAttributeSpecs(bool visibleOnly = false)
        {
            if (AttributeSpecs == null || !AttributeSpecs.Any())
            {
                return(null);
            }

            //Flatten out the AttributeSpecs
            var attributeSpecList = new List <AttributeSpec>(AttributeSpecs);

            IEnumerable <IEnumerable <AttributeSpec> > childattributeSpecLists;

            if (visibleOnly)
            {
                childattributeSpecLists = AttributeSpecs.SelectMany(attributeSpec => attributeSpec.VisibleSubGroupRules)
                                          .Select(attributeRule => attributeRule.Target.GetAllAttributeSpecs());
            }
            else
            {
                childattributeSpecLists = AttributeSpecs.SelectMany(attributeSpec => attributeSpec.SubGroupRules)
                                          .Select(attributeRule => attributeRule.Target.GetAllAttributeSpecs());
            }

            foreach (var childattributeSpecList in childattributeSpecLists)
            {
                attributeSpecList.AddRange(childattributeSpecList);
            }

            return(attributeSpecList);
        }
Example #2
0
        public AttributeSpec FindAttributeSpec(string code)
        {
            if (AttributeSpecs == null || !AttributeSpecs.Any())
            {
                return(null);
            }

            var specInGroup = AttributeSpecs.FirstOrDefault(a => a.Code == code);

            if (specInGroup != null)
            {
                return(specInGroup);
            }

            return(AttributeSpecs.SelectMany(attributeSpec => attributeSpec.SubGroupRules)
                   .Select(attributeRule => attributeRule.Target)
                   .Select(attributeGroup => attributeGroup.FindAttributeSpec(code))
                   .FirstOrDefault(attributeSpec => attributeSpec != null));
        }