Example #1
0
        public override IEnumerable <ActorDefinition> ParseActors(XElement schemeMedium)
        {
            if (schemeMedium == null)
            {
                throw new ArgumentNullException("schemeMedium");
            }

            var actorsElement = schemeMedium.SingleOrDefault("Actors");

            if (actorsElement == null)
            {
                throw new ArgumentNullException("");
            }

            var actors = new List <ActorDefinition>();

            foreach (var element in actorsElement.Elements().ToList())
            {
                ActorDefinition actor = null;
                if (element.Element("IsIdentity") != null)
                {
                    actor = ActorDefinition.CreateIsIdentity(GetName(element), GetId(element.Element("IsIdentity")));
                }
                else if (element.Element("Rule") != null)
                {
                    actor = ActorDefinition.CreateRule(GetName(element), GetRuleName(element.Element("Rule")));
                    var parameters = element.Element("Rule").Elements("RuleParameter");
                    foreach (var parameter in parameters)
                    {
                        actor.AddParameter(GetName(parameter), GetValue(parameter));
                    }
                }
                else if (element.Element("IsInRole") != null)
                {
                    actor = ActorDefinition.CreateIsInRole(GetName(element), GetId(element.Element("IsInRole")));
                }

                if (actor != null)
                {
                    actors.Add(actor);
                }
            }

            return(actors);
        }