Exemplo n.º 1
0
        private AttributeValueWrapBool FindValueWrap(string code, IAttributeContainer container, AttributeGroup rootGroup)
        {
            //First try to locate the ValueWrap in the container
            var valueWrap = container.Attributes.FirstOrDefault(a => a.Code == code) as AttributeValueWrapBool;

            if (valueWrap == null)
            {
                //Otherwise check the spec's assigend ValueWrap (through Initialize)
                var spec = rootGroup.FindAttributeSpec(code) as AttributeSpecBool;
                if (spec == null || spec.ValueWrap == null)
                {
                    throw new NotSupportedException(string.Format("Attribute rule contains operand {0} but has no Attribute with this code defined.", code));
                }

                valueWrap = spec.ValueWrap as AttributeValueWrapBool;
            }
            return(valueWrap);
        }