private Specification CreateAnd(XmlElement node)
        {
            AndSpecification spec = new AndSpecification();

            foreach (XmlElement child in GetChildElements(node))
            {
                spec.Add(BuildNode(child));
            }
            return(spec);
        }
Example #2
0
		/// <summary>
		/// Applies permissions represented by this attribute to an action instance, via the specified <see cref="IActionBuildingContext"/>.
		/// </summary>
		public override void Apply(IActionBuildingContext builder)
        {
            // if this is the first occurence of this attribute, create the parent spec
            if (builder.Action.PermissionSpecification == null)
                builder.Action.PermissionSpecification = new OrSpecification();

            // combine the specified tokens with AND logic
            AndSpecification and = new AndSpecification();
            foreach (string token in _authorityTokens)
            {
                and.Add(new PrincipalPermissionSpecification(token));
            }

            // combine this spec with any previous occurence of this attribute using OR logic
            ((OrSpecification)builder.Action.PermissionSpecification).Add(and);
        }
Example #3
0
        private Specification CreateImplicitAnd(ICollection <XmlNode> nodes)
        {
            if (nodes.Count == 1)
            {
                // only 1 node, so we don't need to "and"
                return(BuildNode((XmlElement)CollectionUtils.FirstElement(nodes)));
            }

            // create an "and" for the child nodes
            var spec = new AndSpecification();

            foreach (XmlElement node in nodes)
            {
                spec.Add(BuildNode(node));
            }
            return(spec);
        }