Ejemplo n.º 1
0
        private List<TriggeringNodeDefinition> BuildTriggeringNodeDefsForStyle(Style s, TriggerCollection triggers)
        {
            List<TriggeringNodeDefinition> results = new List<TriggeringNodeDefinition>();
            TriggeringNodeDefinition tnd = null;

            foreach (XmlNodeInformation ni in s.GetProperties())
            {
                List<TriggeringNodeDefinition> thisNodetriggers =  triggers.WhatDoesThisNodeTrigger(ni, null, null);

                if ((thisNodetriggers != null) && (thisNodetriggers.Count > 0))
                {
                    foreach (TriggeringNodeDefinition etnd in thisNodetriggers)
                    {
                        if (etnd.GetDescriptors().Count > 1)
                            throw new InvalidOperationException(); // we weren't expecting this
                        EffectDescriptor td = etnd.GetDescriptors()[0].Clone();
                        if (ni.GetAttributeValue("val") == "0")
                            td.DefaultPolarity = false;
                        if (tnd != null)
                        {
                            if (tnd.ContentType == td.ContentType)
                                tnd.AddDescriptor(td);
                            else
                                tnd = null;
                        }

                        if (tnd == null)
                        {
                            AttributeFilter af = new ValueAttributeEqualityFilter(s.Id);
                            tnd = new TriggeringNodeDefinition(NamespaceId.w, s.GetReferenceNodeName(), af, td);
                            results.Add(tnd);
                        }
                    }
                }
            }

            return results;
        }